-->
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.  [ 6 posts ] 
Author Message
 Post subject: one to many association
PostPosted: Mon Feb 27, 2006 2:20 am 
Newbie

Joined: Sat Feb 11, 2006 1:47 am
Posts: 9
Location: India
While inserting the data in section master i am facing the Exception as

13:20:25,906 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: beans.master.CatalogueMaster, getter method of property: catalogueId
While fetching the data(which is manually inserted by insert query through DB) from section master i got this exception
15:19:51,187 INFO [STDOUT] Exception in getExistingSection() method of SectionMasterBean.java : org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection
_optimizer=false for more info) setter of beans.master.SectionMaster.setCatalogueId

can anybody help me in this ??????



mapping file contains


Code:
<class name="beans.master.SectionMaster" table="section_master">
      <id name="sectionId" type="int" column="section_id" >
         <generator class="sequence">
             <param name="sequence">section_id_sequence</param>
         </generator>
      </id>
      <property name="sectionName" type="string" not-null="true">
         <column name="section_name" />
      </property>
      <many-to-one name="catalogueId"
            class="beans.master.CatalogueMaster"
            column="catalogue_id"
            not-null="true"/>

      <property name="status" type="string" not-null="true">
         <column name="status" />
      </property>
   </class>

<class name="beans.master.CatalogueMaster" table="catalogue_master">
      <id name="catalogueId" type="int" column="catalogue_id" >
         <generator class="sequence">
             <param name="sequence">catalogue_id_sequence</param>
         </generator>
      </id>
      <property name="catalogueName" type="string" not-null="true">
         <column name="catalogue_name" />
      </property>
      <property name="moderator" type="string">
         <column name="moderator" />
      </property>
      <property name="status" type="string" not-null="true">
         <column name="status" />
      </property>
   
      
   </class>
Table Structures

Table "section_master"
Column | Type | Modifiers
--------------+------------------------+-----------
section_id | integer | not null
section_name | character varying(255) |
catalogue_id | integer | not null
status | character varying(255) |
Primary key: section_master_pkey

Table "catalogue_master"
Column | Type | Modifiers
----------------+------------------------+-----------
catalogue_id | integer | not null
catalogue_name | character varying(255) |
moderator | character varying(255) |
status | character varying(255) |
Primary key: catalogue_master_pkey

Corresponding Pojo classes


Code:
public class CatalogueMaster {

   /**
    *
    */
   public CatalogueMaster() {
      
   }
   private int catalogueId;
   private   String catalogueName;
   private   String moderator;
   private   String status;
         
   /**
    * @return
    */
   public int getCatalogueId() {
      return catalogueId;
   }

   /**
    * @return
    */
   public String getCatalogueName() {
      return catalogueName;
   }

   /**
    * @return
    */
   public String getModerator() {
      return moderator;
   }

   /**
    * @return
    */
   public String getStatus() {
      return status;
   }

   /**
    * @param i
    */
   public void setCatalogueId(int i) {
      catalogueId = i;
   }

   /**
    * @param string
    */
   public void setCatalogueName(String string) {
      catalogueName = string;
   }

   /**
    * @param string
    */
   public void setModerator(String string) {
      moderator = string;
   }

   /**
    * @param string
    */
   public void setStatus(String string) {
      status = string;
   }

}

public class SectionMaster {

   /**
    *
    */
   public SectionMaster() {
      super();
      // TODO Auto-generated constructor stub
   }
   private int sectionId;
   private String sectionName;
   private int catalogueId;
   private String status;
   

   /**
    * @return
    */
   public int getCatalogueId() {
      return catalogueId;
   }

   /**
    * @return
    */
   

   /**
    * @return
    */
   public String getSectionName() {
      return sectionName;
   }

   /**
    * @return
    */
   public String getStatus() {
      return status;
   }

   /**
    * @param i
    */
   public void setCatalogueId(int i) {
      catalogueId = i;
   }

   /**
    * @param i
    */


   /**
    * @param string
    */
   public void setSectionName(String string) {
      sectionName = string;
   }

   /**
    * @param string
    */
   public void setStatus(String string) {
      status = string;
   }

   /**
    * @return
    */
   public int getSectionId() {
      return sectionId;
   }

   /**
    * @param i
    */
   public void setSectionId(int i) {
      sectionId = i;
   }

}

_________________
crack the jack


Last edited by pankie_the_cool on Mon Feb 27, 2006 5:55 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 2:44 am 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
Code:
<id name="primary_key" type="int" column="primary_key" >


Means that you have a colum "primary_key" in your DB and that you map it to an attrbiute names "primary_key", therefore Hibernate expects to find a getter getPrimary_key() or (getPrimary_Key ??)

You should use Java naming conventions and name this attribute primaryKey and have the getter named getPrimaryKey().


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 3:25 am 
Newbie

Joined: Sat Feb 11, 2006 1:47 am
Posts: 9
Location: India
the-gtm wrote:
Code:
<id name="primary_key" type="int" column="primary_key" >


Means that you have a colum "primary_key" in your DB and that you map it to an attrbiute names "primary_key", therefore Hibernate expects to find a getter getPrimary_key() or (getPrimary_Key ??)

You should use Java naming conventions and name this attribute primaryKey and have the getter named getPrimaryKey().


actually i have mentioned that in mapping file under the table1 one as
Code:
<id name="primary_key" type="int" column="primary_key" >


i have corresponding getter for that having same datatype but still it is giving me a problem...

_________________
crack the jack


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 5:46 am 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
I don't get what you mean, could you should your Java classes ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 5:57 am 
Newbie

Joined: Sat Feb 11, 2006 1:47 am
Posts: 9
Location: India
the-gtm wrote:
I don't get what you mean, could you should your Java classes ?


now i have explained my exact problem above i guess now u will get the exact problem.... :)

_________________
crack the jack


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 3:11 pm 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
Okay now I think I get it. In you SectionMaster mapping you've got :

Code:
<many-to-one name="catalogueId"
            class="beans.master.CatalogueMaster"
            column="catalogue_id"
            not-null="true"/>


Which means that SectionMaster has an attribute named catalogueId and whose class is CatalogueMaster. In your SectionMaster class file, this attribute is an int.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.