-->
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.  [ 2 posts ] 
Author Message
 Post subject: many-to-many relationship
PostPosted: Thu Jun 15, 2006 6:33 pm 
Newbie

Joined: Thu Jun 15, 2006 5:58 pm
Posts: 18
Hibernate version 3.1.3 and backend postgres8.0
I have a many-to-many relation between company and location linked by
company_location table
I have defined a set on my company.hbm.xml file
<set name="offices" batch-size = "20" outer-join="auto" cascade="save-update">
<key column="company_id"/>
<one-to-many class="CompanyLocations"/>
</set>

On my CompanyLocation.hbm.xml file (link table)
I have a many-to-one relation to office defined
<many-to-one name= "salesOffice" column="office_id" cascade="none" not-null="true" />

// java code
Object[] tmp = jlstOffices.getSelectedValues();
for(int i = 0 ; i < tmp.length ; ++i)
{
company.getOffices().add((SalesOffice)tmp[i]);
}
When I try to save the company object, I get the error shown below. I
tried debugging the program I could see my persistent set of offices but when the primary key in my linking table is accessed i get this error.

//hibernate3.1.3 error
ERROR - IllegalArgumentException in class: CompanyLocations, getter method of property: cid
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of CompanyLocations.cid


Could some one help me on this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 11:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
There are several reasons for this exception. Do either of these apply to your case:
  • There is a composite-id involved in one of the mappings, but the method named method returns an object of the wrong class (e.g. it should return a CompanyLocationID class, but is returning an Integer).
  • The getCid() method and cid id have different types (int vs. String, etc.)
There are other ways that this can happen, but I can't recall them off-hand. Post again with more details, larger mapping posts (ids are vital), and, of course, code tags.

_________________
Code tags are your friend. Know them and use them.


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

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.