-->
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.  [ 11 posts ] 
Author Message
 Post subject: Hibernate bug, or new way to do inheritance?
PostPosted: Wed Jun 01, 2005 11:52 am 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
I can't believe I am the only one here to encounter this, the simplest inheritance problem you can have. I posted my problem in this thread:

http://forum.hibernate.org/viewtopic.ph ... highlight=

Nobody came forward with suggestions.

In summary, I inherited my POJO in a class that holds my business logic. That new class won't persist. Why? It did under 2.x. Is there something I am doing wrong? I am happy to open a very detailed bug report if appropriate, but in any event, I cannot go forward because of this problem.

Can someone please advise?

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 12:31 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I'm not a Hibernate expert, but I'm working on a project that uses Hibernate Synchronizer, which sets up a similar class hierarchy to yours (abstract base POJOs and extending 'business' classes). I recently migrated it from H2 to H3, and didn't have your problem. Maybe you have additional problems, and your class hierarchy isn't the cause.

I would suggest trying lazy="false" on your class mappings, to rule out cglib first.

Good luck.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 3:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to specify ALL classes you want to persist in the mappings.

in the simplets form is just a <subclass name="blah"/>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: <subclass> = death to extended classes
PostPosted: Wed Jun 01, 2005 5:17 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
Max, using the <subclass> element just deleted my class with the business logic, which is exactly what I don't want.

How does one persist a class that extends a POJO? This used to work.

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject: Hibernate bug, or new way to do inheritance?
PostPosted: Wed Jun 01, 2005 7:33 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
Nathanmoon:
adding the lazy = false didn't have any effect. Thanks for the suggestion though.

I might point out to others that <subclass> is not the solution to this problem, because it causes the hibernate system to generate the specified class. If you extend a class, the extended class *is* an instance of the superclass, so it makes no sense to me that you would have to do *anything* special. I am still in the dark as to how to solve this problem.

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 1:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh ? so your problem is with hbm2java, right ?

Use <meta attribute="generated-class">BaseXXX</meta> to have hbm2java generate a class you can extend to avoid overwritting your concrete class.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: meta attributes to solve inheritance recognition?
PostPosted: Thu Jun 02, 2005 8:46 am 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
Well, no, my problem isn't with hbm2java, it's with hibernate for not recognizing that when A extends APOJO, that A really is APOJO and should persist it.

Hbm2java is a problem when I try to use the subclass attribute to solve that problem, because hbm2java then generates this subclass.

Is using a meta attribute going to cause regeneration? Seems like it would since you're telling me that it causes hbm2java to generate a class in the first place.

The mapping files and stack trace describing this can be found here:
http://forum.hibernate.org/viewtopic.ph ... highlight=

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 2:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
add a feature requst to allow no generation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: inheritance works for hibernate synchronizer in H3
PostPosted: Thu Jun 02, 2005 3:25 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
nathanmoon pointed out that hibernate synchronizer uses the same inheritance scheme that I do, and that he moved such a project from H2 to H3 with no problems.

So what am I doing wrong? Others, nathanmoon in particular, are getting the desired results from hibernate 3.

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 4:41 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Just a shot in the dark - Hibernate Synchronizer declares the base POJOs to be abstract. You could see if making your POJOs abstract helps at all. I think you can do that with hbm2java using:

Code:
<meta attribute="scope-class">public abstract</meta>


Top
 Profile  
 
 Post subject: hibernate synchronizer's magic
PostPosted: Thu Jun 02, 2005 5:48 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
Thanks for the suggestion nathanmoon. It made the POJO abstract, but I am still stuck with the same error.

_________________
--Pierce Krouse


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