2 Replies Latest reply on Jan 19, 2007 5:25 AM by micho

    naming of attributes in queries

    micho

      Hi,

      I have a curious problem defining attributes in queries.

      I defined the attributes with different names as the gettermethod.
      for example: attribute:mId, getter: getId()] (missing "m").

      I get the following exception when defining my querey like this:

      javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.QueryException: could not resolve property: mId of: com.babuco.entity.testdel [from com.babuco.entity.testdel t where t.mId = :id and t.mName = :name]
      

      I can´t find a rule how I have to name the Attributes in my query.




        • 1. Re: naming of attributes in queries
          andydale

          Hi,

          Could you post up some your entity code, and the actual query you are trying to get to work.

          Cheers,

          Andy

          • 2. Re: naming of attributes in queries
            micho

             

            @Entity
            @Table(name = "Benutzer")
            public class User implements Serializable
            { private long mSid;
             private long mMandantID;
             private String mId;
            
             public User() { super(); }
             public String getId() { return mId; }
             public void setId(String pId) { mId = pId; }
             @Id @GeneratedValue(strategy=GenerationType.AUTO)
             public long getSid() { return mSid; }
             public void setSid(long pSid) { mSid = pSid; }
             public long getMandantID() { return mMandantID; }
             public void setMandantID(long pMandantID) { mMandantID = pMandantID; }
            }
            

            List<User> erg = (List<User>) em.createQuery(
            "from User where (Id = :uid) and (pwd=:pwd) and (mandantID=:mandantid)")
            .setParameter ("uid", pUserName).setParameter ("pwd", pPwd).setParameter ("mandantid", lMandantID).getResultList();
            

            this works,
            mandantID, mandantid insted of MandantID works too
            but id insted of Id doesn´t.