These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error using <set> with joined-subclass
PostPosted: Wed Mar 23, 2005 4:11 pm 
Newbie

Joined: Sat Feb 26, 2005 10:10 pm
Posts: 8
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.