-->
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: one to many error
PostPosted: Wed Aug 09, 2006 12:26 pm 
Beginner
Beginner

Joined: Wed Aug 09, 2006 12:09 pm
Posts: 20
Location: Belgium
Hello. I have hibernate with spring up and running and now am trying to make my first relationship between tables.

I have a table frameworks and a table ammendments. Which is a one to many relationship. In table ammendments I have a column frameID which relates to the primary key in table frameworks.

In my framework.hbm.xml file I have this:
Code:
<class name="be.eurodyn.costDB.model.Framework"
     table="cdb_framework">

     <id name="frameworkID" column="frameworkID">
   <generator class="identity" />
     </id>

  <property name="frameworkDESC" type="string" />
  <property name="frameworkVisible" type="integer" />
  <property name="frameworkActive" type="integer" />
  <property name="frameworkACYN" type="string" />
  <set name="frameID"           
    lazy="false"
    table="cdb_ammendment"
    fetch="join">
   <key column="frameID"/>
   <one-to-many class="be.eurodyn.costDB.model.Ammendment"/>
  </set>


and in my framework class I have getters and setters for frameID (the reason for this is I was getting an error that there were no getters and setters in my Framework class, although surely they should not be needed as the frameID is defined in the Ammendment class not the Framework class and stored in the Ammendment table!!!! )

in my Ammendment.hbm.xml file I have frameID as a property
Code:
<property name="frameID" type="integer" />


When I deploy the application I get this error
Code:
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of be.eurodyn.costDB.model.Framework.setFrameID


These are my setters and getters in the framework class
Code:
public int getFrameID() {
   return frameID;
}
public void setFrameID(int frameID) {
   this.frameID = frameID;
}


Does anyone have any idea what might be going on here. All I am trying to do is a simple one-to-many relationship, this has got to be easy surely. I have spent a day and a half trying to sort this out and it is not making any sense. It must be easier than this surely.

Thanks for taking the time to read. Any hints or tips are much appreciated.

cheers
Martin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 12:44 pm 
Newbie

Joined: Wed Dec 07, 2005 1:27 pm
Posts: 8
Martin,

You are correct that you should not have frameId getters and setters in your framework class. But you should have getters and setters for all the properties (frameworkDESC, frameworkVisible, etc...), as well as for the set of amendments (which you have called frameID, but you might want to call amendments instead, which would be a clearer name).

Kevin


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.