-->
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.  [ 4 posts ] 
Author Message
 Post subject: table-per-hiearchy with interface at root?
PostPosted: Wed Feb 23, 2005 1:02 pm 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
(FYI, I've read all the FAQs, searched the forum, and read the hmtl docs, read the HIA book. I've seen several posts on interface mappings, but all seemed to dead-end with no definitive answer.)

- I would like to persist a hiearchy of classes implementing an interface with no shared base class.
- I don't want to declare 'getId, getVersion, etc' in the interface (I'm using aspectwerkz to introduce these methods as a mixin to the concrete classes.)
- I want table-per-hierarchy

Can I get table-per-hierarchy without a base class?

I have defined a mapping against the interface, which included

<id name="id">
<generator class="native"/>
</id>
<discriminator type="string"/>
<version name="version"/>

And had the concrete mappings extend this. But of course this required getId, getVersion in the interface. This is what I'm trying to eliminate. Is there a way to achieve this?

thanks!

-barry


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 7:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Interesting question.

So, you have everything implementing an interface. Then all the implementers define the same-named version and id property. I think you can handle this by writing a custom PropertyAccessor, but add something to JIRA, cos I think we can be a little less strict in one of our checks, and make this work.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 4:46 pm 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
One of the common issues I run into is that the business interface often does not define a setter for a property. Since hibernate requests this getter while parsing the config file, I wrote a custom PropertyAccessor that defers the creation of the Getter/Setter until get/set is actually called.

However, without a common base class defering Getter/Setter creation fails as the method to set the property will be different for the concrete classes, while hibernate stores only a single setter as part of the interface info.

It seems what is needed to solve this problem is to define a class mapping that whose definition are inherited by extending classes, but is not processed independently (ie, config file inheritance only).

Is this what you think can be done Gavin? It would seem that the 2.1 branch would need much refactoring to make this possible since the xml parsing and the processing of the xml are intertwinded. I have not yet looked at the 3.x codebase. Is it different there? Or am I just missing something else?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 4:51 pm 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
BTW, my underlying motivation is to introduce persistence into a project completly as an aspect. eg, One project defines pure business concerns and a second project defines the mappings; introduces Persistable interface along with default method impls of getId, setVersion, etc; introduces a default no-arg constructor; etc.


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