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.  [ 3 posts ] 
Author Message
 Post subject: hbm2java throws ClassCastException
PostPosted: Tue Jan 27, 2004 2:49 am 

Joined: Sat Oct 18, 2003 10:44 am
Posts: 3
Location: Orange County, CA
When running hbm2java either by command line or from the Ant task, it throws a ClassCastException whenever I use any <meta> tags.

I have tried moving a single meta tag to the <hibernate-mapping> scope and inside <class> tags and always get the same error.

I'm using hibernate 2.1 and I tried the last release of the hibernate-tools and also built it from the HEAD tag.

Any help would be greatly appreciated. Hibernate works great for me but I can't force my team to use it without the <meta> tags working. I've worked on this problem on and off for a couple of months and just can't seem to get it resolved.

Here is the stack trace:
[hbm2java] java.lang.ClassCastException: java.util.ArrayList
[hbm2java] at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.mergeMetaMaps(MetaAttributeHelper.java:91)
[hbm2java] at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.loadAndMergeMetaMap(MetaAttributeHelper.java:112)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.initWith(ClassMapping.java:162)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.<init>(ClassMapping.java:76)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.handleClass(CodeGenerator.java:129)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:104)

 Post subject:
PostPosted: Thu Feb 05, 2004 5:02 pm 

Joined: Wed Dec 31, 2003 4:26 am
Posts: 108
Location: Berkeley, CA
Hmmm. The first thing that pops into mind is that you are specifying a java.util.ArrayList. This is perhaps for some association?? Well, Hibernate requires that you not use actual Collection classes but only Collection interfaces: e.g., List, not ArrayList, so that Hibernate can then sneakily substitute its own implementations. Those implementations are essential to the dynamic resolution of relationships: e.g., lazy loading. So, off the cuff, that's the first change I'd make.

Second, post more of the mapping file. This error looks familiar but the mapping will give better insight.

 Post subject:
PostPosted: Thu Feb 05, 2004 5:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this looks like a waay old bug ;)

are you sure you are using the latest ?

Don't forget to rate

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