-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with the class (getter method of property: id)
PostPosted: Sun Apr 23, 2006 8:18 pm 
Newbie

Joined: Mon Apr 10, 2006 3:32 pm
Posts: 13
I have this problem. Please... How can i fix it?

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

The class that have the getid
public void setid(BigInteger home)
{
id = home;

}
public BigInteger getid()
{
return id;
}
Hibernate version:
3.0

Mapping documents:
<class name="Honey" table="honey" >

<composite-id>
<key-property name="id"/>
</composite-id>
<property name="name"></property>
<property name="taste" type="string" update="true"></property>
<many-to-one name="id" column="id" class="casa" insert="false" update="false" />

</class>

<class name="casa" table="casa">
<id name="id" column="id"></id>

<property name="name" column="name"></property>
</class>
Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
01:11:18,004 ERROR BasicPropertyAccessor:167 - IllegalArgumentException in class: de.laliluna.example.casa, getter method of property: id

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of de.laliluna.example.casa.id

at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)

at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)

at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)

at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)

at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)

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:263)

at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)

at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)

at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)

at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)

at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:559)

at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)

at org.hibernate.impl.SessionImpl.save(SessionImpl.java:543)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)

at $Proxy0.save(Unknown Source)

at de.laliluna.example.TestExample.createHoney(TestExample.java:162)

at de.laliluna.example.TestExample.main(TestExample.java:50)

Caused by: java.lang.IllegalArgumentException: this is not an instance of the method's owning class

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)

... 26 more



Name and version of the database you are using:
Mysql

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 9:06 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Why have you set up id as a composite-id when it clearly isn't? This could be made to work with the composite id, as the problem is simply that you're putting a simple type somewhere that a composite type is expected. However, changing id to a simple id will also work, and it's a better solution.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 10:37 pm 
Newbie

Joined: Mon Apr 10, 2006 3:32 pm
Posts: 13
Thanks Tenwir for answer my question...

Im using <composite-id> 'cause the id its a foreign key its the id from the table "casa" .... So which its the way to declare that a element its a foreign key?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 10:37 pm 
Newbie

Joined: Mon Apr 10, 2006 3:32 pm
Posts: 13
Thanks Tenwit for answer my question...

Im using <composite-id> 'cause the id its a foreign key its the id from the table "casa" .... So which its the way to declare that a element its a foreign key?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 10:43 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Set it up the normal way, using <id>. Use the "foreign" generator. You should add unique="true" to the inverse mappig (the many-to-one), and call it "Casa". id is the value, it has the same value as casa's id.

This is the source of your exception. Your mapping says that "id" is of type "Casa", but your java says it's of type BigInteger. id should be a BigInteger in your mapping, and you should have a separate Casa field, being the inverse reference.


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