-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Null pointer exception with @StaticMetamodel
PostPosted: Sun Oct 30, 2011 3:46 am 
Newbie

Joined: Sun Sep 04, 2011 10:26 am
Posts: 4
Hello, I am trying to create a type-safe criteria query.

this is my function:

Code:
@Override
   public List<QuestionnaireClient> read(String questionnaireId) {
      CriteriaQuery<QuestionnaireClient> criteria = getEntityManager().getCriteriaBuilder().createQuery(QuestionnaireClient.class);
      
      Root<QuestionnaireClient> client = criteria.from(QuestionnaireClient.class);
      
      Path<String> questionnaireIdPath = client.get(QuestionnaireClient_.questionnaireId);
      
      criteria.where(getEntityManager().getCriteriaBuilder().equal(questionnaireIdPath, questionnaireId));
      
      TypedQuery<QuestionnaireClient> query = getEntityManager().createQuery(criteria);
      
      List<QuestionnaireClient> pesristedClients = query.getResultList();

      return pesristedClients;
   }


I get a null pointer exception on line 3:
Path<String> questionnaireIdPath = client.get(QuestionnaireClient_.questionnaireId);

Now, this is the entity:
Code:
@Entity
@Table(name = "clients")
@Inheritance(strategy = InheritanceType.JOINED)
public class QuestionnaireClient implements Serializable {

   /* --- Members --- */

   /** Serial version unique id */
   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(generator = "uuid")
   @GenericGenerator(name = "uuid", strategy = "uuid")
   private String id;

   @Version
   private int version;

   @Enumerated(EnumType.STRING)
   private IdType idType;

   private String clientId;

   private String fullName;

   private String shortPassportId;

   @Enumerated(EnumType.STRING)
   private RelationToAccount accountRelation;

   private boolean isParticipating;

   private boolean isEditable;

   private String questionnaireId;


This is the meta model class:
Code:
@StaticMetamodel(QuestionnaireClient.class)
public class QuestionnaireClient_ {

   public static volatile SingularAttribute<QuestionnaireClient, Long> serialVersionUID;
   public static volatile SingularAttribute<QuestionnaireClient, String> id;
   public static volatile SingularAttribute<QuestionnaireClient, Integer> version;
   public static volatile SingularAttribute<QuestionnaireClient, String> idType;
   public static volatile SingularAttribute<QuestionnaireClient, String> clientId;
   public static volatile SingularAttribute<QuestionnaireClient, String> fullName;
   public static volatile SingularAttribute<QuestionnaireClient, String> shortPassportId;
   public static volatile SingularAttribute<QuestionnaireClient, String> accountRelation;
   public static volatile SingularAttribute<QuestionnaireClient, Boolean> isParticipating;
   public static volatile SingularAttribute<QuestionnaireClient, Boolean> isEditable;
   public static volatile SingularAttribute<QuestionnaireClient, String> questionnaireId;
}


I also tried to create the metamodel class with only the wanted line which is:
public static volatile SingularAttribute<QuestionnaireClient, String> questionnaireId;

I got the same result.

Can anyone please help me?

Thank you,
Ido


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.