-->
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.  [ 8 posts ] 
Author Message
 Post subject: Modularization of my application.
PostPosted: Sat Sep 20, 2003 1:32 pm 
Newbie

Joined: Sat Sep 20, 2003 1:09 pm
Posts: 8
Hello,

I am about to split my application into a 'base' with (optional) 'modules'.
The base and modules will persist classes using hibernate.

Most of these classes in the modules are specific to that module.
But sometimes the module will have to extend a persistent class
of the 'base'.
For instance :
I have a base-class "Article".
The module "Lot-tracking" will extend this Article with the
property "LotNumber" (and several others).

So "Article" will get an extra property when the module "Lot-tracking"
is activated.

So I'm looking for a way to 'expand' to a hmb.xml-file.
I now I can do it with ant and an xslt-transformation, but I would
like to see it as a standard feature in hibernate.
Maybe mark the expansion with an attribute.
maybe something like :

The Article in the 'base' :
Code:
<hibernate-mapping>
  <class name="Article" table="Article">
     <property name="Code"/>
     <property name="Name"/>
  </class>
</hibernate-mapping>


Expanding the Article in module 'Lot-tracking' :
Code:
<hibernate-mapping>
  <class name="Article" table="Article" expand="true">
     <property name="LotNumber"/>
  </class>
</hibernate-mapping>


Any thoughts on this ?

Kees Kuip.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 20, 2003 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Have you looked at the subclass mapping element?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 20, 2003 3:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
subclass and joined-subclass now supports an extends attribute and can be used to extend existing mapped classes.

This is a new feature in Hibernate 2.1 and is currently only availbale in the v21branch

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 21, 2003 6:31 am 
Newbie

Joined: Sat Sep 20, 2003 1:09 pm
Posts: 8
steve wrote:
Have you looked at the subclass mapping element?


Yes, I looked at it, but I do not want to subclass "Article".
There will be more than one module which will need to 'expand' the "Article".
So subclass which has single-inheritance is no solution.


Kees.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 21, 2003 7:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
keeskuip wrote:
steve wrote:
Have you looked at the subclass mapping element?


Yes, I looked at it, but I do not want to subclass "Article".
There will be more than one module which will need to 'expand' the "Article".
So subclass which has single-inheritance is no solution.


Kees.


That's evil! ;)

You should just allow for your modules to overrule the Article definitions then! How do you handle extending your own compiled classes ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: subclassing is evil !
PostPosted: Sun Sep 21, 2003 9:25 am 
Newbie

Joined: Sat Sep 20, 2003 1:09 pm
Posts: 8
Quote:
That's evil! ;)


Why is that evil ?

Subclassing for no apparent reason is evil !
You can read every design-book on that.

Quote:
How do you handle extending your own compiled classes ?


I generate my compiled classes (with velocity), so there is no problem.

Kees.


Top
 Profile  
 
 Post subject: Re: subclassing is evil !
PostPosted: Sun Sep 21, 2003 10:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
keeskuip wrote:
Quote:
That's evil! ;)


Why is that evil ?

Subclassing for no apparent reason is evil !
You can read every design-book on that.

Quote:
How do you handle extending your own compiled classes ?


I generate my compiled classes (with velocity), so there is no problem.

Kees.


Ok - so it's not like you want one part of your system having Article and some other part of the system Article + the extras.

You just want Article + extras allover ?

Then why not generate your hbm.xmls with velocity or combine them with xml external entities or something ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 21, 2003 11:34 am 
Newbie

Joined: Sat Sep 20, 2003 1:09 pm
Posts: 8
Yes, thats what I'm doing right now.

But I thought it would be nice if was in standard Hibernate.

Thanks,
Kees.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.