net.sf.hibernate.PropertyNotFoundException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I gote a table "usr" with the column "e_Mail" with following description: <property name="eMail" type="java.lang.String" column="e_mail" length="255" /> retrieving a query leads to following error: net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property eMail in class com.sbs.tsw.hibernate.Usr at net.sf.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:131) at net.sf.hibernate.mapping.Property.getSetter(Property.java:182) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:734) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:741) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) at com.sbs.tsw.model.HibernateUtil.<clinit>(HibernateUtil.java:28) at com.sbs.tsw.model.QuotationHandler.main(QuotationHandler.java:25) Checking this in cvs(v21final) I found following in method "private static Method setterMethod(Class theClass, String propertyName)"(line 159) : String testStdMethod = Introspector.decapitalize( methodName.substring(3) ); This returns "EMail" in testStdMethod when methodName="setEMail" !!! I would expect "eMail" and when I changed this to something like: String testStdMethod = methodName.substring(3,4).toLowerCase()+methodName.substring(4); everything works fine ?! So what is Introspector.decapitalize doing here?
    via by Andre Schikore,
  • I gote a table "usr" with the column "e_Mail" with following description: <property name="eMail" type="java.lang.String" column="e_mail" length="255" /> retrieving a query leads to following error: net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property eMail in class com.sbs.tsw.hibernate.Usr at net.sf.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:131) at net.sf.hibernate.mapping.Property.getSetter(Property.java:182) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:734) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:741) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) at com.sbs.tsw.model.HibernateUtil.<clinit>(HibernateUtil.java:28) at com.sbs.tsw.model.QuotationHandler.main(QuotationHandler.java:25) Checking this in cvs(v21final) I found following in method "private static Method setterMethod(Class theClass, String propertyName)"(line 159) : String testStdMethod = Introspector.decapitalize( methodName.substring(3) ); This returns "EMail" in testStdMethod when methodName="setEMail" !!! I would expect "eMail" and when I changed this to something like: String testStdMethod = methodName.substring(3,4).toLowerCase()+methodName.substring(4); everything works fine ?! So what is Introspector.decapitalize doing here?
    via by Andre Schikore,
  • Our dataclass has following getters and setters, which looks very JavaBean conform. The problem is the "i" in iCondition. The problem is it is alone there.. private int iCondition; public int getICondition() { return iCondition; } public void setICondition(int iCondition) { this.iCondition = iCondition; } Here is the corresponding mapping: ... <property name="description"/> <property name="ends"/> <property name="iCondition" column="condition"/> <many-to-one name="seller" not-null="true"/> ... The error is: 16:01:04,634 INFO SessionFactoryImpl:119 - building session factory net.sf.hibernate.PropertyNotFoundException: Could not find a getter for iCondition in class org.hibernate.auction.AuctionItem at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182) at net.sf.hibernate.mapping.Property.getGetter(Property.java:175) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:733) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:714) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768) at org.hibernate.auction.Main.main(Main.java:419) Exception in thread "main" When I make the property iiCondition and make getters and setters for it, it does work. It seems like the reflection part does work but the concatenating of the "get"+xxxxxx has something wrong in setting the characters to uppercase...
    via by marcel thiel,
  • Hi, In my mapping file I have a property mapped like this: <property name="tProp" type="string"/> In my java business object the property is represented as follow: private String tProp; /** * @return */ public String getTProp() { return tProp; } /** * @param string */ public void setTProp(String string) { tProp = string; } When I launch my application I got the following error: [junit] net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tProp in class com.airfrance.comor.enterpriselayer.businessobject.Escale [junit] at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182) [junit] at net.sf.hibernate.mapping.Property.getGetter(Property.java:175) [junit] at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:740) [junit] at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:716) [junit] at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42) [junit] at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136) [junit] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791) [junit] at com.airfrance.jraf.provider.persistence.hibernate.Initializer.initialize(Initializer.java:137) I got the same error if I change the type in the mapping and in the business object class. If I change the property name to 'tprop' in the mapping file and in the business object class it works perfectly. I got the same problem in multiple environment (Wesphere 5.1, JUnit Test...). I think the bug is on hibernate side. Contact me if you need more precisions. Cordially, Eric
    via by eric bellard,
  • Hibernate (2.1.6) has a problem with database column names containing underscores in the name. I have a database table containing a column called T_SYS_USERGROUP_ID and this column causes a PropertyNotFoundException exception (see full exception trace at the bottom of this message) when I include it in my Configuration with a .addClass call. The SQL code for the table definition looks like this: CREATE TABLE T_USER ( userID VARCHAR2 ( 50 ) DEFAULT USER NOT NULL, Enabled VARCHAR2 ( 1 ) DEFAULT 'Y' NOT NULL, T_SYS_USERGROUP_ID NUMBER NOT NULL, LOGIN_TIME DATE, LOGOFF_TIME DATE, create_time DATE DEFAULT SYSDATE NOT NULL, create_user VARCHAR2 ( 50 ) DEFAULT USER NOT NULL, modify_time DATE DEFAULT SYSDATE NOT NULL, modify_user VARCHAR2 ( 50 ) DEFAULT USER NOT NULL, CONSTRAINT PK_T_User0 PRIMARY KEY (userID) ) The mapping file (auto generated by ddl2hbm) for the table looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="hibernate.TUser" schema="CHTS" table="T_USER"> <id column="USERID" name="id" type="long"> <generator class="sequence"/> </id> <property column="ENABLED" length="1" name="enabled" not-null="true" type="string"/> <property column="T_SYS_USERGROUP_ID" length="22" name="tSysUsergroupId" not-null="true" type="long"/> <property column="LOGIN_TIME" length="7" name="loginTime" type="date"/> <property column="LOGOFF_TIME" length="7" name="logoffTime" type="date"/> <property column="CREATE_TIME" length="7" name="createTime" not-null="true" type="date"/> <property column="CREATE_USER" length="50" name="createUser" not-null="true" type="string"/> <property column="MODIFY_TIME" length="7" name="modifyTime" not-null="true" type="date"/> <property column="MODIFY_USER" length="50" name="modifyUser" not-null="true" type="string"/> </class> </hibernate-mapping> The Java source for the setter and getter code for column 'T_SYS_USERGROUP_ID' (auto generated by hbm2java) looks like this: public long getTSysUsergroupId() { return this.tSysUsergroupId; } public void setTSysUsergroupId(long tSysUsergroupId) { this.tSysUsergroupId = tSysUsergroupId; } The above setter and getter causes the PropertyNotFoundException. If I manually change the signature of these methods to this: public long gettSysUsergroupId() { return this.tSysUsergroupId; } public void settSysUsergroupId(long tSysUsergroupId) { this.tSysUsergroupId = tSysUsergroupId; } and recompile the Java class everything works! Note that this bug seems to be related to #HB-1197 This is a showstopper for my Hibernate project, so I hope it will be looked at soon! Best regards, Bo Skjoett Software Engineer Full exception: net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tSysUsergroupId in class hibernate.TUser at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182) at net.sf.hibernate.mapping.Property.getGetter(Property.java:175) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:740) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:716) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791) at Main.main(Main.java:74) Exception in thread "main"
    via by Bo Christian Skjoett,
  • If one has a variable like: aEndTerminal The getter/setter are generated corectly by the code generator, BUT: Because the getter/setter changes aEndTerminal to AEndTerminal, we got into this later on: net.sf.hibernate.PropertyNotFoundException: Could not find a getter for aEndTerminal in class com.im.Trail at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:571) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:665) at net.sf.hibernate.persister.PersisterFactory.create(PersisterFactory.java:29) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:207) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627) at com.im.Main.initHibernate(Main.java:42) at com.im.Main.go(Main.java:48) at com.im.Main.main(Main.java:35) Exception in thread "main The problem is Introspector.decapitalize() It has a "special case" that we're hitting, quote from javadoc: " This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone." I've created a copy of Introspector.decapitalize inside ReflectHelper.java without the "special case" , replaced all calls to Introspector.decapitalize with my new 'decapitalize' and all works like a charm. So in my opinion Introspector.decapitalize should not be used in the RelectHelper !!! This kind of bug surfaces when the variable begins with one single lower case character followed by an upper case character !! Thanks, --sherban
    via by Sherban Popescu,
    • net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property eMail in class com.sbs.tsw.hibernate.Usr at net.sf.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:131) at net.sf.hibernate.mapping.Property.getSetter(Property.java:182) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:734) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:741) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) at com.sbs.tsw.model.HibernateUtil.<clinit>(HibernateUtil.java:28) at com.sbs.tsw.model.QuotationHandler.main(QuotationHandler.java:25)
    No Bugmate found.