-->
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: problems with many-to-many relations with hbm2java
PostPosted: Tue Sep 13, 2005 10:51 am 
Newbie

Joined: Thu Sep 08, 2005 12:37 pm
Posts: 10
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello,

I got problems in hbm2java with many-to-many associations. The Mapping are added hereafter. Using hbm2ddl everything works as exspected but with hbm2java I get an error indicating ClassCastExceptions org.hibernate.mapping.ManyToOne ... which I do not use explicitely.

I used an extented version with lazy="true" and cascade="save-update" but the error remains the same.

Best regards
Oliver-Arne

Hibernate version:
From Hibernate-Tools 3.1 alpha 5

Mapping documents:

Code:
<hibernate-mapping package="de.oc.shipment.entities">
<class name="N" table="N" lazy="true">
   <id name="id" type="long" column="N_ID">
         <generator class="native"/>
      </id>
      <set
         name="ms"
         table="M_N">
         <key column="N_ID"/>
         <many-to-many
            class="de.oc.shipment.entities.M"
            column="M_ID">
         </many-to-many>
      </set>
      
   </class>
</hibernate-mapping>


and

Code:
<hibernate-mapping package="de.oc.shipment.entities">
<class name="M" table="M" lazy="true">
      
      <id name="id" type="long" column="M_ID">
         <generator class="native"/>
      </id>
      <set
         name="ns"
         table="M_N"
         inverse="true">
         <key column="M_ID"/>
         <many-to-many
            class="de.oc.shipment.entities.N"
            column="N_ID">
         </many-to-many>
      </set>
      
   </class>
</hibernate-mapping>



Full stack trace of any exception that occurs:

Extracted from calling ant -debug hbm2java

Code:
Finding class org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl
Loaded from C:\Dokumente und Einstellungen\oah\workspace\Cargo-Shipment\lib\velocity-1.4.jar org/apache/velocity/util/introspection/UberspectImpl$VelGetterImpl.class
Class org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl loaded from ant loader (parentFirst)
[hibernatetool] java.lang.ClassCastException: org.hibernate.mapping.ManyToOne
[hibernatetool]    at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:572)
[hibernatetool]    at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:488)
[hibernatetool]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[hibernatetool]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[hibernatetool]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatetool]    at java.lang.reflect.Method.invoke(Method.java:585)
[hibernatetool]    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:267)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:197)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:327)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:128)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:220)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55)
[hibernatetool]    at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:166)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:70)
[hibernatetool]    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
[hibernatetool]    at org.apache.velocity.Template.merge(Template.java:256)
[hibernatetool]    at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450)
[hibernatetool]    at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:419)
[hibernatetool]    at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:82)
[hibernatetool]    at org.hibernate.tool.hbm2x.POJOExporter.runVelocity(POJOExporter.java:79)
[hibernatetool]    at org.hibernate.tool.hbm2x.POJOExporter.exportPersistentClass(POJOExporter.java:61)
[hibernatetool]    at org.hibernate.tool.hbm2x.POJOExporter.start(POJOExporter.java:111)
[hibernatetool]    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
[hibernatetool]    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
[hibernatetool]    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool]    at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool]    at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool]    at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool]    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool]    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool]    at org.apache.tools.ant.Main.runBuild(Main.java:673)
[hibernatetool]    at org.apache.tools.ant.Main.startAnt(Main.java:188)
[hibernatetool]    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[hibernatetool]    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[hibernatetool] 16:42:07,386 ERROR template:94 - Method getJavaTypeName threw exception for reference $c2j in template pojo/javaclass.vm at  [37,55]
[hibernatetool] 16:42:07,386 ERROR template:94 - Method getJavaTypeName threw exception for reference $c2j in template pojo/javaclass.vm at  [37,36]


Name and version of the database you are using:
Oracle 10g R1


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 3:49 pm 
Newbie

Joined: Wed Sep 14, 2005 3:38 pm
Posts: 5
sounds like my issue which is referenced in this post: (now bumped)

http://forum.hibernate.org/viewtopic.php?t=945953


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.