-->
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: org.hibernate.PropertyAccessException: IllegalArgumentExcept
PostPosted: Mon Jul 25, 2005 1:21 pm 
Newbie

Joined: Mon Jul 25, 2005 12:58 pm
Posts: 5
Hi. I've been having a trouble figureing out what I did wrong with the getter. I have a one to many relationship between table Company and CompanyListing. Company has companyId(PK), name. I'm trying to have CompanyListing associated with Comapny by using FK companyId. If anyone can give me any tips how to solve this problem, I would appreciate it very much.

Hibernate version:3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.adsmack.framework.domain">

<class name="Company" table = "company">
<id name="companyId">
<generator class="native"/>
</id>
<property name="name"/>
<set name = "companyListingList" inverse = "true" lazy = "true">
<key column = "companyId"/>
<one-to-many class = "CompanyListing"/>
</set>
</class>

<class name="CompanyListing" table = "companylisting">
<id name="id" column = "id">
<generator class="native"/>
</id>
<property name="displayName"/>
<property name="pictureURL"/>
<property name="websiteURL"/>
<property name="companyEmail"/>
<property name="shortDescription"/>
<property name="longDescription"/>

<many-to-one name = "companyId" class = "Company" column = "companyId"/>
<bag name = "companyCategoryList" table = "companycategory_companylisting">
<key column = "CompanyListingId" />
<many-to-many class = "CompanyCategory" column = "CompanyCategoryId"/>
</bag>
</class>

<class name="CompanyCategory" table = "companycategory">
<id name="id" column = "id">
<generator class="native"/>
</id>
<property name="categoryName1"/>
<property name="categoryName2"/>
<property name="categoryName3"/>
</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Session s = factory.openSession();
Transaction tx = s.beginTransaction();

Long generatedID = (Long) s.save(theCompanyListing);
theCompanyListing.setId(generatedID);
tx.commit();


Full stack trace of any exception that occurs:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.adsmack.framework.domain.Company.companyId
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:103)
at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2947)
at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2724)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:175)
at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:137)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:232)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:158)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:429)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:424)
at com.adsmack.framework.persistence.hibernateDAO.HibernateCompanyDAO.createCompanyListing(HibernateCompanyDAO.java:109)
at com.adsmack.framework.business.helpers.CompanyHelper.createCompanyListing(CompanyHelper.java:117)
at com.adsmack.framework.persistence.TestCompanyHelper.testCreateCompanyListing(TestCompanyHelper.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
... 35 more



Name and version of the database you are using:MySQL 4.1.12


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:57 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 12:21 pm
Posts: 22
Location: Sacramento CA, USA
PropertyAccessException can be caused because of many reason. Some are
1) Type Casting
2) Null field in the DB assigned to a primitive type.

Check the JavaDoc for this error you may get more info.
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/PropertyAccessException.html


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.