Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0rc1
Mapping documents:
Code:
<class name="Item" table="item">
<id
name="pkId"
column="id"
type="long">
<generator class="native"/>
</id>
<property name="type" column="type" />
<property name="status" column="status"/>
<!joined-subclass name="Component" extends="Item" table="component">
<key column="id"/>
<set name="entries" inverse="true" cascade="all">
<key column="comp_id"/>
<one-to-many class="Entry"/>
</set>
</joined-subclass>
<joined-subclass name="Entry" extends="Item" table="component_entry">
<many-to-one name="compId" column="comp_id" class="Component" not-null="true"/>
<property name="propertyame" column="property"/>
<property name="value" column="default_value"/>
</joined-subclass>
</class>
Code between sessionFactory.openSession() and session.close():
Component t = new Component ();
if (tname == null) {
tname = getName() + " Component ";
}
t.setName(tname);
Entry entry1 = new Entry();
entry1.setName(tname + "entry");
t.addEntry(entry1);
... beginTransaction()
session.save(t)
... commitTransaction();
Full stack trace of any exception that occurs:
12:07:29,853 ERROR BasicPropertyAccessor:115 - IllegalArgumentException in class: Item, getter method of property: pkId
IllegalArgumentException occurred calling getter of Item.pkId
Name and version of the database you are using:sqlserver200
The generated SQL (show_sql=true):
This mapping works if I convert it into a union-subclass (not really what I want).
If I remove the line from the mapping
<many-to-one name="compId" column="comp_id" class="Component" not-null="true"/>
I will get a constraint violation exception instead of this one.
In BasicPropertyAccessor, tt seems like Hibernate is trying to call getPkId from entityName="Component", but entity class is actually a long. That's why it throws the error.
Thanks!
Theen-Theen