-->
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: Problem with 1:n-relation
PostPosted: Fri Oct 31, 2008 6:22 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hi everybody,

there is a 1:n-relation between my classes Person and City.

I get the following error:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of de.waldhausweg7.model.City.persons
org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
org.hibernate.loader.Loader.doQuery(Loader.java:729)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
org.hibernate.type.EntityType.resolve(EntityType.java:379)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
org.hibernate.loader.Loader.doQuery(Loader.java:729)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.doList(Loader.java:2220)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
org.hibernate.loader.Loader.list(Loader.java:2099)
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
de.waldhausweg7.service.PersonService.getPersonList(PersonService.java:136)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:99)
com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:187)
com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:171)
com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
javax.faces.component.UIData.getValue(UIData.java:547)
com.icesoft.faces.component.panelseries.UISeries.getDataModel(UISeries.java:310)
com.icesoft.faces.component.panelseries.UISeries.processCurrentRowData(UISeries.java:138)
com.icesoft.faces.component.panelseries.UISeries.setRowIndex(UISeries.java:130)
com.icesoft.faces.component.ext.renderkit.TableRenderer.renderFacet(TableRenderer.java:140)
com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:115)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:703)
javax.faces.component.UIData.encodeBegin(UIData.java:701)
com.icesoft.faces.component.panelseries.UISeries.encodeBegin(UISeries.java:251)
javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:613)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:565)
com.icesoft.faces.component.DataTableTag.doEndTag(DataTableTag.java:732)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:237)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:157)
com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:508)
com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:161)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:268)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:25)
com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:161)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:30)
com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:48)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:139)
com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
org.hibernate.loader.Loader.doQuery(Loader.java:729)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
org.hibernate.type.EntityType.resolve(EntityType.java:379)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
org.hibernate.loader.Loader.doQuery(Loader.java:729)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.doList(Loader.java:2220)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
org.hibernate.loader.Loader.list(Loader.java:2099)
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
de.waldhausweg7.service.PersonService.getPersonList(PersonService.java:136)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:99)
com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:187)
com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:171)
com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
javax.faces.component.UIData.getValue(UIData.java:547)
com.icesoft.faces.component.panelseries.UISeries.getDataModel(UISeries.java:310)
com.icesoft.faces.component.panelseries.UISeries.processCurrentRowData(UISeries.java:138)
com.icesoft.faces.component.panelseries.UISeries.setRowIndex(UISeries.java:130)
com.icesoft.faces.component.ext.renderkit.TableRenderer.renderFacet(TableRenderer.java:140)
com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:115)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:703)
javax.faces.component.UIData.encodeBegin(UIData.java:701)
com.icesoft.faces.component.panelseries.UISeries.encodeBegin(UISeries.java:251)
javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:613)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:565)
com.icesoft.faces.component.DataTableTag.doEndTag(DataTableTag.java:732)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:237)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:220)
com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:157)
com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:508)
com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:161)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:268)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:25)
com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:161)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:30)
com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:48)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:139)
com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


Here my City.hbm.xml:

Code:
<?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 default-lazy="false" auto-import="false">
   <class name="de.waldhausweg7.model.City" table="city">
      <id name="cityId" column="cityid" type="int">
         <generator class="increment" />
      </id>
      <property name="postalCode" column="postalcode" />
      <property name="cityName" column="cityname" />
      
      <!-- 1:n-Beziehung zu Person -->
      <set name="persons" cascade="none" lazy="true">
         <key column="cityId" />
         <one-to-many class="de.waldhausweg7.model.Person" />
      </set>
   </class>   
</hibernate-mapping>



And my Person.hbm.xml

Code:
<?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 default-lazy="false" auto-import="false">
   <class name="de.waldhausweg7.model.Person" table="Person">
      <id name="personId" type="int">
         <generator class="increment" />
      </id>
      <property name="firstName" column="firstName" />
      <property name="surName" column="surName" />
      <property name="street" column="street" />
      <property name="extraAddressLine" column="extraAddressLine" />
      <property name="phone" column="phone" />
      <property name="mobile" column="mobile" />
      <property name="fax" column="fax" />
      <property name="email" column="email" />
      <property name="comment" column="comment" />
      
      <!-- 1:n-Beziehung zu Ort -->
      <many-to-one name="city" column="cityId" class="de.waldhausweg7.model.City" />
   </class>
</hibernate-mapping>



My getter and setter for persons in City.java

Code:
private City selectedCity;

   public List<Person> getPersons() {      
      return persons;
   }

   public void setPersons(List<Person> persons) {
      this.persons = persons;
   }


Does anybody know, what I did wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 6:30 am 
Newbie

Joined: Fri Oct 31, 2008 6:27 am
Posts: 4
What if you try to use a Set in your java class instead of a List ?


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.