-->
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: Howto - Mapping abstract base class using tpc-strategy
PostPosted: Tue Mar 09, 2004 7:44 am 
Newbie

Joined: Tue Mar 09, 2004 7:25 am
Posts: 2
Hi all,

I know that this question was send at least a thousand times, but I haven't found a
satifying answer (Or I'm blind :-).

I try to map the following class structure to a datamodel:

public interface BusinessObject {
long getId();
void setId(long id);
String getUserId();
void setUserId(String userid);
Date getChangeDate();
void setChangeDate(Date aDate);
Object getBusinessId();
void setBusinessId(Object businessId);
}

public class AbstractBusinessObject implements BusinessObject {
// implementation of BusinessObject interface (getter and setter)
}

public interface Person extends BusinessObject {
String getName();
void setName(String aName);
// .. some other properties
}

public class PersonImpl extends AbstractBusinessObject implements Person {
// implementation of Person interface (getter and setter)
}

I would like to subclass all my business objects from the abstract base class, thus
i have to implement the four properties only once, but store only the concrete classes
in an appropriate table.

What is the best practice approch to map this?
Is it possible to store the BusinessObject and AbstractBusinessObject in a jar file different to
Person and PersonImpl (for SchemaExport)? (of course bind it to classpath).

I would grateful for any comment. A link to a thread would be equal :-).
Thanks for your help
Per


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
duplicate column mapping in your hbm.xml

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 3:40 am 
Newbie

Joined: Tue Mar 09, 2004 7:25 am
Posts: 2
Hi emmanuel,

thanks for the reply.

emmanuel wrote:
duplicate column mapping in your hbm.xml


Ok this is an alternative. But is it "Best practice" too? I thought to something more
modular. Like mapping the BusinessObject to one file and put it in jar A and "derive"
the person mapping from the business object mapping and put it in jar B.

I've read the manual and saw the table-per-concrete strategy. But i havn't understood it
really.

A second alternative is IMHO a xml include. But is it possible to store both mapping files
in different jars?

Thx for your help,
Per


Top
 Profile  
 
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.