net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tSysUsergroupId in class hibernate.TUser

Hibernate JIRA | Bo Christian Skjoett | 1 decade ago
  1. 0

    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"

    Hibernate JIRA | 1 decade ago | Bo Christian Skjoett
    net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tSysUsergroupId in class hibernate.TUser
  2. 0

    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"

    Hibernate JIRA | 1 decade ago | Bo Christian Skjoett
    net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tSysUsergroupId in class hibernate.TUser
  3. 0

    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

    Hibernate JIRA | 1 decade ago | eric bellard
    net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tProp in class com.airfrance.comor.enterpriselayer.businessobject.Escale
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    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

    Hibernate JIRA | 1 decade ago | eric bellard
    net.sf.hibernate.PropertyNotFoundException: Could not find a getter for tProp in class com.airfrance.comor.enterpriselayer.businessobject.Escale

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. net.sf.hibernate.PropertyNotFoundException

      Could not find a getter for tSysUsergroupId in class hibernate.TUser

      at net.sf.hibernate.property.BasicPropertyAccessor.getGetter()
    2. net.sf.hibernate
      Configuration.buildSessionFactory
      1. net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182)
      2. net.sf.hibernate.mapping.Property.getGetter(Property.java:175)
      3. net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:740)
      4. net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:716)
      5. net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
      6. net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
      7. net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
      7 frames
    3. Unknown
      Main.main
      1. Main.main(Main.java:74)
      1 frame