IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JPA Java Discussion :

StaticMetamodel - NullPointerException


Sujet :

JPA Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Développeur informatique
    Inscrit en
    Juillet 2007
    Messages
    167
    Détails du profil
    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 167
    Par défaut StaticMetamodel - NullPointerException
    Bonjour,

    je suis comme qui dirais un peu énervé...

    Hier, j'ai développé un jolie code (?!) qui semblait fonctionné (test unitaire ok) et aujourd'hui, plus rien ne marche.

    j'ai maintenant une NullPointerException lors de l'appel de ce même code...

    Merci d'avance pour vos réponses.

    Si joint mon dao, entité et metamodels

    dao:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    public class DoogooderDaoImp extends
    		AbstractDaoEntityManager<DooGooderEntity, Long> implements DoogooderDao {
     
    	/**
             * @param em
             */
    	public DoogooderDaoImp(EntityManager em) {
    		super(em, DooGooderEntity.class);
    		this.em = em;
    	}
     
    	@Override
    	public void delete(DooGooderEntity entity) {
    		// em.remove(entity);
    		entity.getDoogooderStatus().setId(new Long(4));
    		em.persist(entity);
    	}
     
    	@Override
    	public DooGooderEntity findByNamePassword(String login, String pwd)
    			throws NoResultException, NonUniqueResultException {
    		CriteriaBuilder cb = em.getCriteriaBuilder();
    		CriteriaQuery<DooGooderEntity> query = cb
    				.createQuery(DooGooderEntity.class);
    		Root<DooGooderEntity> rootDg = query.from(DooGooderEntity.class);
    		Predicate loginPredicate, pwdPredicate;
    		SingularAttribute<DooGooderEntity, String> attLogin = DoogooderEntityMetaModel.login;
    		loginPredicate = cb.equal(rootDg.get(attLogin), login);
    		pwdPredicate = cb.equal(rootDg.get(DoogooderEntityMetaModel.password), pwd);
    		query.where(loginPredicate, pwdPredicate);
    		return em.createQuery(query).getSingleResult();
    	}
    }
    meta model:
    PS: depuis ce matin, si mon metamodel se nomme DoogooderEntity_, je plante lors du démarrage avec une belle NoClassDefFoundError
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    @StaticMetamodel(DooGooderEntity.class)
    public abstract class DoogooderEntityMetaModel {
     
    	public static volatile SingularAttribute<DooGooderEntity, Long> id;
    	public static volatile SingularAttribute<DooGooderEntity, String> firstname;
    	public static volatile SingularAttribute<DooGooderEntity, String> name;
    	public static volatile SingularAttribute<DooGooderEntity, String> email;
    	public static volatile SingularAttribute<DooGooderEntity, String> login;
    	public static volatile SingularAttribute<DooGooderEntity, String> password;
    	public static volatile SingularAttribute<DooGooderEntity, String> memberId;
    	public static volatile SingularAttribute<DooGooderEntity, Date> birthdate;
    	public static volatile SingularAttribute<DooGooderEntity, String> phone;
    	public static volatile SingularAttribute<DooGooderEntity, String> mobile;
    	public static volatile SingularAttribute<DooGooderEntity, String> gender;
    	public static volatile SingularAttribute<DooGooderEntity, Date> premiumTill;
    	public static volatile SingularAttribute<DooGooderEntity, UserRoleEntity> userRole;
    	public static volatile SingularAttribute<DooGooderEntity, DooGooderStatus> doogooderStatus;
    	public static volatile SingularAttribute<DooGooderEntity, String> userName;
    	public static volatile SingularAttribute<DooGooderEntity, String> language;
    	public static volatile CollectionAttribute<DooGooderEntity, Collection<DoogooderAddressEntity>> addressList;
    	public static volatile CollectionAttribute<DooGooderEntity, Collection<Point>> points;
     
    }
    entité:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
     
    @Entity
    @Table(name = DooGooderEntity.TABLE_NAME, uniqueConstraints = { @UniqueConstraint(columnNames = {
    		"id", "memberId" }) })
    public class DooGooderEntity {
     
    	public static final String TABLE_NAME = "tbl_doogooder";
     
    	public static final String FIELD_DOOGOODER_ID = "id";
     
    	@Id
    	@GeneratedValue
    	@Column
    	private long id;
     
    	@Column(length = 50)
    	private String firstname;
     
    	@Column(length = 50)
    	@NotEmpty
    	private String name;
     
    	@Column(length = 100)
    	// @NotEmpty
    	private String email;
     
    	@Column(length = 20)
    	// @NotEmpty
    	private String login;
     
    	@Column(length = 20)
    	// @NotEmpty
    	private String password;
     
    	@Column(length = 20)
    	// @NotEmpty
    	private String memberId;
     
    	// @NotEmpty
    	private java.sql.Date birthdate; // only store date
     
    	@Column(length = 15)
    	// @NotEmpty
    	private String phone;
     
    	@Column(length = 15)
    	private String mobile;
     
    	@Column(length = 5)
    	private String gender;
     
    	@Column
    	private java.sql.Date premiumTill;
     
    	@JoinColumn(name = "userRoleid")
    	@OneToOne
    	private UserRoleEntity userRole;
     
    	@JoinColumn(name = "doogooderStatusid")
    	@OneToOne
    	private DooGooderStatus doogooderStatus;
     
    	@Column(length = 50)
    	private String userName;
     
    	@Column(length = 5)
    	private String language;
     
    	@OneToMany(mappedBy = DoogooderAddressEntity.DOOGOODER_FIELD_NAME, cascade = CascadeType.ALL)
    	private Collection<DoogooderAddressEntity> addressList;
     
    	@OneToMany(mappedBy = Point.DOOGOODER_FIELD_NAME, cascade = CascadeType.ALL)
    	private Collection<Point> points;

  2. #2
    Membre confirmé
    Développeur informatique
    Inscrit en
    Juillet 2007
    Messages
    167
    Détails du profil
    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 167
    Par défaut Solution trouvée


    c'est plutôt simple... le metamodel doit se nommé comme l'entité (avec à la fin _ ou ... ) et se trouver dans le même package

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [JDBC][STATEMENT] NullPointerException
    Par syvid dans le forum JDBC
    Réponses: 2
    Dernier message: 23/03/2005, 00h29
  2. [Débutant]NullPointerException
    Par Crazyblinkgirl dans le forum Langage
    Réponses: 4
    Dernier message: 18/08/2004, 13h58
  3. [Exception]Double buffering & NullPointerException
    Par Seiya dans le forum API standards et tierces
    Réponses: 25
    Dernier message: 09/07/2004, 18h41
  4. Heritage et NullPointerException
    Par Assiobal dans le forum Langage
    Réponses: 6
    Dernier message: 18/06/2004, 16h35
  5. JPanel & getGraphics() : NullPointerException
    Par dingoth dans le forum Composants
    Réponses: 7
    Dernier message: 21/05/2004, 15h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo