We have a problem with certain attribute names in persistent classes.
This is just a quick notification, in case the problem is unknown. (I couldn't find anything related to the problem).
We generate both Java code and SQL DDL from .hbm.xml files. We had two boolean attributes, named "aSupplier" and "pSupplier". Hibernate code generation generated getter and setter methods:
public boolean isASupplier()
public void setASupplier(boolean aSupplier)
public boolean isPSupplier()
public void setPSupplier(boolean pSupplier)
When trying to initialize hibernate at runtime we got the following exception:
2005.02.16 01:20:46 CET net.sf.hibernate.PropertyNotFoundException: Could not find a getter for aSupplier in class de.xxx.ums.data.impl.CompanyData
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.NormalizedEntityPersister.<init>(NormalizedEntityPersister.java:719)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:45)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
at de.volkswagen.ums.persistence.hibernate.HibernateFactoryGenerator.init(HibernateFactoryGenerator.java:132)
at de.volkswagen.ums.persistence.hibernate.HibernateFactoryGenerator.getSessionFactory(HibernateFactoryGenerator.java:47)
at de.volkswagen.ums.persistence.hibernate.HibernateSessionManager.init(HibernateSessionManager.java:54)
at de.volkswagen.ums.persistence.hibernate.HibernateSessionManager.<init>(HibernateSessionManager.java:32)
at de.volkswagen.ums.persistence.hibernate.HibernateSessionManager.getInstance(HibernateSessionManager.java:43)
at de.volkswagen.ums.persistence.hibernate.HibernateTransaction.<init>(HibernateTransaction.java:42)
...
I browsed through the hibernate code of BasicPropertyAccessor, and it seemed the problem might be related to the capitalization of the name.
I changed the attribute names to asupplier resp. psupplier. The generated accessor methods are now:
public boolean isAsupplier()
public void setAsupplier(boolean aSupplier)
public boolean isPsupplier()
public void setPsupplier(boolean pSupplier)
With these names hibernate runs without prolems.
Hibernate version: 2.1.6 (yes I know there is now a 2.1.8, and i will try to reproduce the problem with 2.1.8 when i got the time.)
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="de.xxx.ums.data.impl.OrganizationData" table="ums_organization">
<!-- meta attribute="extends">com.jmyra.util.CountableObject</meta -->
<meta attribute="implements">de.xxx.ums.data.impl.IBaseDataObject</meta>
<id name="oid" column="oid" type="string" unsaved-value="null">
<generator class="de.xxx.ums.persistence.hibernate.OIDGenerator"/>
</id>
<version name="version" column="version" type="int"/>
<property name="source" column="source" type="string" length="32" not-null="false"/>
<many-to-one name="address" column="address_oid" class="de.xxx.ums.data.impl.AddressData" cascade="all"/>
<many-to-one name="comm" column="comm_oid" class="de.xxx.ums.data.impl.CommunicationData" cascade="all"/>
<set name="attributes" cascade="all" inverse="true" lazy="true">
<key column="owner_oid"/>
<one-to-many class="de.volkswagen.ums.data.impl.AttributeData"/>
</set>
<joined-subclass name="de.xxx.ums.data.impl.CompanyData" table="ums_company">
<key column="com"/>
<property name="duns" column="duns" type="string" length="9" not-null="true"/>
<property name="name" column="name" type="string" length="128" not-null="true"/>
<property name="asupplier" column="a_supplier" type="boolean" not-null="true"/>
<property name="psupplier" column="p_supplier" type="boolean" not-null="true"/>
</joined-subclass>
<joined-subclass name="de.xxx.ums.data.impl.OrgUnitData" table="ums_org_unit">
<key column="org"/>
<property name="orgUnitShort" column="org_unit_short" type="string" length="8" not-null="true"/>
<property name="orgUnitLong" column="org_unit_long" type="string" length="64" not-null="true"/>
<property name="kst" column="kst" type="string" length="16" not-null="true"/>
<property name="kstDescriptionKey" column="kst_description_key" type="string" length="128" not-null="true"/>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): N/A
Full stack trace of any exception that occurs: see above
Name and version of the database you are using: Oracle 8.x
The generated SQL (show_sql=true): n/a
Debug level Hibernate log excerpt: n/a
|