-->
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 bei "Bidirectional Association Mapping"
PostPosted: Wed Jan 03, 2007 12:51 pm 
Newbie

Joined: Wed Jan 03, 2007 12:00 pm
Posts: 2
Wie in der Hibernate Anleitung(3.2.0) im Kapitel 7.4.1 versuche ich eine bidirektionale One-to-Many Assoziation abzubilden. Wenn ich die Datensätze versuche zu laden, egal ob SQL oder HQL Query erhalte ich eine Exception.

Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dataObjects.Command.refCheckCommandHost


Hibernate version:
hibernate-3.2.1.ga.zip

Java Klassen
Code:
public class Host {
   
   private String OID = "";
   private Command hostCheckCommand = null;

   public Command getHostCheckCommand() {
      return hostCheckCommand;
   }
   public String getOID() {
      return OID;
   }
   public void setHostCheckCommand(Command hostCheckCommand) {
      this.hostCheckCommand = hostCheckCommand;
   }
   public void setOID(String oid) {
      OID = oid;
   }
}

public class Command {
   
   private String OID = "";
   private TreeSet<Host> refCheckCommandHost = null;

   public String getOID() {
      return OID;
   }
   public TreeSet<Host> getRefCheckCommandHost() {
      return refCheckCommandHost;
   }
   public void setOID(String oid) {
      OID = oid;
   }
   public void setRefCheckCommandHost(TreeSet<Host> refCheckCommandHost) {
      this.refCheckCommandHost = refCheckCommandHost;
   }
}



Mapping documents:
Code:
<class name="Command" table="command">
      <id name="OID">
         <generator class="uuid" />
      </id>
      
      <set name="refCheckCommandHost " inverse="true">
         <key column="hostcheckcommand" />
         <one-to-many class="Host" />
      </set>
</class>


Code:
<class name="Host" table="host">
   <id name="OID">
      <generator class="uuid" />
   </id>
   
   <many-to-one name="hostCheckCommand" column="hostcheckcommand" />

      
</class>


DB Tabellen:
Code:
CREATE TABLE host (

   OID                        varchar(64) UNIQUE PRIMARY KEY,
   hostcheckcommand            varchar(64) REFERENCES command (OID)
);

CREATE TABLE command (
   
   OID                        varchar(64) UNIQUE PRIMARY KEY
);



Code between sessionFactory.openSession() and session.close():
Code:
   java.util.List x = session.createQuery("from TimePeriod").list();


Full stack trace of any exception that occurs:
Code:
Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dataObjects.Command.refCheckCommandHost
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
   at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
   at org.hibernate.loader.Loader.doQuery(Loader.java:717)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2211)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
   at org.hibernate.loader.Loader.list(Loader.java:2090)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at dataObjects.ServerSet.loadServerSetFromDB(ServerSet.java:57)
   at test.testSimpleDBConnection.main(testSimpleDBConnection.java:19)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
   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$BasicSetter.set(BasicPropertyAccessor.java:42)
   ... 17 more
17:21:17,802 ERROR BasicPropertyAccessor:94 - IllegalArgumentException in class: dataObjects.Command, setter method of property: refCheckCommandHost
17:21:17,802 ERROR BasicPropertyAccessor:98 - expected type: java.util.TreeSet, actual value: org.hibernate.collection.PersistentSet


Name and version of the database you are using:
PostgreSQL 8.2

The generated SQL (show_sql=true):
Code:
17:21:17,652 DEBUG SQL:393 - select command0_.OID as OID0_, command0_.commandName as commandN2_0_, command0_.commandLine as commandL3_0_, command0_.beforedefinition as beforede4_0_, command0_.afterdefinition as afterdef5_0_, command0_.shellcommand as shellcom6_0_ from command command0_
Hibernate: select command0_.OID as OID0_, command0_.commandName as commandN2_0_, command0_.commandLine as commandL3_0_, command0_.beforedefinition as beforede4_0_, command0_.afterdefinition as afterdef5_0_, command0_.shellcommand as shellcom6_0_ from command command0_


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 4:02 pm 
Newbie

Joined: Wed Jan 03, 2007 12:00 pm
Posts: 2
Habe glaube ich hier eine Lösung gefunden:

http://forum.hibernate.org/viewtopic.ph ... f97c7a06b5


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.