-->
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.  [ 11 posts ] 
Author Message
 Post subject: net.sf.hibernate.PropertyAccessException:while calling sette
PostPosted: Tue Jun 22, 2004 12:02 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
I was doing so well with the Hibernate config guys, so well, but now I have my connections to the DB working it is throwing the following errors;

Code:
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dto.schedules.Schedule.id IllegalArgumentException occurred while calling setter of dto.schedules.Schedule.id


I have 2 objects Schedule and DataAcquisitionSchedule which extends Schedule. All members of the 2 objects are private but there are setter and getter methods for each. Here is my Schedule object for example;

Code:
package com.qas.newmedia.intranet.iq.dto.schedules;

import java.util.Date;

/**
* Schedule
*/
public class Schedule {
   
   private int id;
   private String status;
   private String title;
   private String summary;
   private String description;
   private Date created;
   private Date lastUpdated;

   public void setId(int id) {
      this.id = id;
   }
   
   public int getId() {
      return this.id;
   }
   
   public void setStatus(String status) {
      this.status = status;
   }
   
   public String getStatus() {
      return this.status;
   }
   
   public void setTitle(String title) {
      this.title = title;
   }
   
   public String getTitle() {
      return this.title;
   }
   
   public void setSummary(String summary) {
      this.summary = summary;
   }
   
   public String getSummary() {
      return this.summary;
   }
   
   public void setDescription(String description) {
      this.description = description;
   }
   
   public String getDescription() {
      return this.description;
   }
   
   public void setCreated(Date created) {
      this.created = created;
   }
   
   public Date getCreated() {
      return this.created;
   }
   
   public void setLastUpdated(Date lastUpdated) {
      this.lastUpdated = lastUpdated;
   }
   
   public Date getLastUpdated() {
      return this.lastUpdated;
   }
}




and here is my call to Hibernate where I do not specify an ID because this is an auto id provided by the DB.

Code:
try {
         Session session = HibernateUtil.currentSession();
         try {
            session.connection().setCatalog("dbSchedules");
         } catch (SQLException sqlE) {
            logger.error(sqlE.getMessage());
         }
         Transaction tx = session.beginTransaction();
   
         DataAcquisitionSchedule schedule = new DataAcquisitionSchedule();
         
         schedule.setStatus("Test Stat");
         schedule.setTitle("Test");
         schedule.setSummary("Test Summ");
         schedule.setDescription("Test Desc");
         schedule.setProductName("P Name");
         schedule.setProductRelease("4");
   
         session.save(schedule);
         tx.commit();
         HibernateUtil.closeSession();
         
      } catch (HibernateException hE) {
         logger.error(hE + " " + hE.getMessage());
      }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:04 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Show your mapping files and other stuff mentioned in the red box.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:07 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
sorry :(

Hibernate: 2.1
SQL Server 2000

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- <property name="connection.datasource">java:comp/env/jdbc/schedules</property> -->
      <property name="hibernate.connection.username">sa</property>
      <property name="hibernate.connection.password">blah</property>
      <property name="hibernate.connection.url">jdbc:jtds:sqlserver://intratestgbr:1433/dbSchedules;charset=Cp1252;TDS=7.0</property>
      <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>   
        <property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
      <property name="show_sql">true</property>
      <property name="hibernate.hbm2ddl.auto">create</property>

        <!-- Mapping files -->
        <mapping resource="com/qas/newmedia/intranet/iq/dto/schedules/Schedule.hbm.xml"/>

    </session-factory>

</hibernate-configuration>



Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="com.qas.newmedia.intranet.iq.dto.schedules.Schedule" table="Schedules">

        <id name="id" type="long" column="schedule_id">
           <generator class="identity" />
       </id>
            
        <property name="status" column="status" not-null="true" />
      <property name="title" column="title" not-null="true" />
      <property name="summary" column="summary" not-null="true" />
      <property name="description" column="description" not-null="true" />
      <property name="created" type="date" column="created" not-null="false" />
      <property name="lastUpdated" type="date" column="last_updated" not-null="false" />
      
      <joined-subclass
         name="com.qas.newmedia.intranet.iq.dto.schedules.DataAcquisitionSchedule"
         table="DataAcquisitionSchedules">
         
           <key column="schedule_id" />
         
         <property name="productName" column="productName" not-null="true" />
         <property name="productRelease" column="productRelease" not-null="true" />

       </joined-subclass>

    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Code:
private int id;


[code]<id name="id" type="long" column="schedule_id">

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:14 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
Hm, I am guessing you want me to spot something really obvious? I am only a beginner, so I would say that the only thing obvious is that I use long in the ID element rather than int???

I changed my config to

Code:
<id name="id" type="int" column="schedule_id">
        <generator class="identity" />
</id>


And this throws the same error still. If you meant something else I don't suppose I could ask you ever so nicely for the answer ;)

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Are you sure you are running the fixed version? This is the only error in your files, the rest is fine.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:23 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
All I know is that I downloaded Hibernate 2 days ago after searching the web for a solution to mapping OOP to RDBMSs. I thought I had acquired the most recent version although I see some ppl are mentioning version 3, so perhaps I got an old version? I will check the download site again.

This is the only error I get

Code:
2004-06-22 17:12:34,673 ERROR com.qas.newmedia.intranet.iq.logic.schedules.ScheduleLogic.test1(Unknown Source) : net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.qas.newmedia.intranet.iq.dto.schedules.Schedule.id IllegalArgumentException occurred while calling setter of com.qas.newmedia.intranet.iq.dto.schedules.Schedule.id


and my stdout contains

Code:
Hibernate: insert into Schedules (status, title, summary, description, created, last_updated) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into DataAcquisitionSchedules (productName, productRelease, schedule_id) values (?, ?, ?)


which is correct.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I wasn't talking about the Hibernate version, but the version of your code. Are you sure you are using an "int" mapping, not a long?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:35 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
you are right, it was an old version. this works fine now. hibernate rocks! thanks for your time :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:36 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
ok, this is annoying. I have just tried to reproduce it again by reverting ALL my settings to the same as this morning and now I cannot get Hibernate to prepend the schema.

I am off home now but I will try again tomorrow. I am convinced that I was at least a little bit right, but for now you seem to be correct.

Sorry for wasting your time :)


Top
 Profile  
 
 Post subject: Re: net.sf.hibernate.PropertyAccessException:while calling s
PostPosted: Thu Jun 24, 2004 3:23 pm 
Newbie

Joined: Mon Jun 21, 2004 3:43 pm
Posts: 19
Quote:

and here is my call to Hibernate where I do not specify an ID because this is an auto id provided by the DB.



Could you let me know how you make your DB provide he auto id?


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