Hi everyone,
I am using the SchemaExport tool with the following mapping:
<hibernate-mapping package="com.frs.model">
<class name="CustomerAttribute" table="customer_attribute">
<composite-id
name="customer_attribute_pk"
unsaved-value="none">
<key-property name="customerId" type="integer" column="customer_id"/>
<key-property name="name" column="name" type="string" length="256"/>
<key-property name="value" column="value" type="string" length="256"/>
</composite-id>
<property
column="create_dt"
name="createDt"
not-null="true"
type="date"
/>
<many-to-one name="customer" class="Customer" column="customer_id" foreign-key="customer__id_fk1"/>
</class>
</hibernate-mapping>
I recieve the following error when I run the SchemaExport tool:
net.sf.hibernate.PropertyNotFoundException: field not found: customer_attribute_pk
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
at net.sf.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:90)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:286)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:174)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:289)
Seems the tool is looking for the composite-id class, which I do not want to define since it generates an unnecessary class. Anyway to get around this?
i.e. if I edit the composite key to:
<composite-id
name="customer_attribute_pk"
unsaved-value="none"
class="something">
<key-property name="customerId" type="integer" column="customer_id"/>
<key-property name="name" column="name" type="string" length="256"/>
<key-property name="value" column="value" type="string" length="256"/>
</composite-id>
The error goes away.
Thanks!
Scott.
|