-->
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.  [ 5 posts ] 
Author Message
 Post subject: hibernate, xDoclet and subclass
PostPosted: Tue Feb 24, 2004 8:17 am 
Newbie

Joined: Tue Feb 24, 2004 8:08 am
Posts: 4
hi all

im new to hibernate and try to create a class hierarchy which is persited using hibernate.
i create the hbm.xml files using xDoclet and everything is fine if i dont have any subclasses. but when i run xDoclet it does not create the mapping files for
Quote:
@hibernate.subclass
and i run into problems when exporting the schema.

what tags are required to create subclass mapping files ?
what is the preferred scheme (one table per class, one table per hierarchy...)


thanks for your help

rema[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 10:38 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
Parent Class...
@hibernate.class table="User" discriminator-value="U"
@hibernate.discriminator column="subclass" type="character"

All SubClasses...
@hibernate.subclass discriminator-value="C"
(with different value for each class)

You must declare the discriminator. Read the docs it's all there.

http://www.hibernate.org/hib_docs/reference/html/inheritance.html

hope this helped


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 4:45 pm 
Newbie

Joined: Tue Sep 28, 2004 4:13 pm
Posts: 3
I believe what you're missing is that the subclass also has to be declared as a class in and of itself...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 2:46 pm 
Newbie

Joined: Tue Sep 28, 2004 4:13 pm
Posts: 3
Scratch my last post. However, I am having the same issue. XDoclets are as follows:

Code:

Event.java:
* @hibernate.class
*      table="EVENT_LOG"
*      polymorphism="implicit"
*
* // Not fully-qualified!
* @hibernate.discriminator
*      column="EVENT_TYPE"
*      type="string"
*      length="64"
*

*/
public abstract class Event implements Serializable { with some columns and an ID, EVENT_TYPE not listed as a column. }


DocEvent.java:
* @hibernate.subclass
*      discriminator-value="DocEvent"
*   
*
*     
*/
public class DocEvent extends Event { 1 more ancillary column... }



This only generates Event.hbm.xml - with the subclass properly listed inside and all that - but not DocEvent.hbm.xml. The subsequent problem is:

Code:
14:38:06,729  INFO net.sf.hibernate.cfg.Configuration:347 - Mapping resource: com/whoever/util/logger/DocEvent.hbm.xml
------------- ---------------- ---------------

Testcase: testSingleEvent took 2.141 sec
   Caused an ERROR
Error instantiating database persistence layer: Resource: com/whoever/util/logger/DocEvent.hbm.xml not found
com.whoever.util.logger.EventException: Error instantiating database persistence layer: Resource: com/whoever/util/logger/DocEvent.hbm.xml not found
   at...



Questions: 1. Should there be a DocEvent.hbm.xml generated?
2. If not, why is this failing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 3:25 pm 
Newbie

Joined: Tue Sep 28, 2004 4:13 pm
Posts: 3
Grumble... problem found. The .hbm.xml it was searching for had been programmatically declared elsewhere, unbeknownst to me.

Rema - go find where your subclass is loaded programmatically, or in your .cfg.xml file, and blow it away. You don't need the mapping file for the subclass - just make sure the subclass info is in the class' mapping file.


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