-->
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.  [ 1 post ] 
Author Message
 Post subject: multiple set() methods on the same property in a POJO
PostPosted: Fri Jun 10, 2005 3:03 pm 
Newbie

Joined: Wed Nov 12, 2003 3:49 pm
Posts: 19
If a POJO has multiple set() methods for the same property (with different signatures, of course), which one does Hibernate use?

I have set up a mapping and the following works just fine:

Code:
public void setProp(String val)  {this.prop = new Prop(val);}


However, I get an Exception when I add a second set method, such as:
Code:
public void setProp(Prop val)  {this.prop = val;}

It seems like whenever I have two setters with different signatures for the same property, I get an exception. I have tried various combinations of property types and set methods, and it seems that my basic problem is that two setters on the same property generates an exception.

Is there a way that I can persuade Hibernate to use the correct setter and ignore the others?

Thanks,
Dave

<hr/>

Here is the exception:


org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dtpitb.businessobjects.invivo.InvivoExperimentPlain.expID

at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:70)

at org.hibernate.tuple.AbstractTuplizer.setPropertyValues(AbstractTuplizer.java:207)

at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:176)

at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)

at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)

at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)

at org.hibernate.loader.Loader.doQuery(Loader.java:436)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)

at org.hibernate.loader.Loader.doList(Loader.java:1593)

at org.hibernate.loader.Loader.list(Loader.java:1577)

at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)

at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at dtpitb.businessobjects.invivo.InvivoHibernateTestProgram.main(InvivoHibernateTestProgram.java:32)

Caused by: java.lang.IllegalArgumentException: argument type mismatch

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$BasicSetter.set(BasicPropertyAccessor.java:40)

... 14 more

14:45:56,500 ERROR BasicPropertyAccessor:66 - expected type: dtpitb.wrappers.ExpIDInvivo, actual value: java.lang.String

Exception in thread "main"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.