-->
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: Mapping Problem
PostPosted: Fri Nov 28, 2003 12:10 pm 
Newbie

Joined: Fri Nov 28, 2003 11:36 am
Posts: 2
I have two classes defined:

public class ApplicationSpecification implements Serializable {
private String id;
private String vendor;
private String name;
private String version;
private boolean rebootRequired;
private java.lang.String installationNotes;
private String description;
private boolean licenced;
}

public class ApplicationInstance extends ApplicationSpecification {
private String appInstId;
private String installationOrder;
private String notes;
private String businessUnit;
private String buildVersion;
private String language;
private String descriptor;
private boolean visible;
private String version;
}


One ApplicationSpecification is the specification for many ApplicationInstances. An ApplicationInstance is a superclass of a Specification, but they do not have the same primary id. An ApplicationInstance also has its own id.

To model this in the database I have separate tables that map exactly to the Specification and Instance tables.

The Specification table has a PK of AS_ID.
The Instance table also has a PK of AI_ID.
The Instance table also has a FK into Specification, namely AI_AS_ID.

How do I model this within the XML mapping document?

Any help would be appreciated with this as I have been working on this problem for a couple of days now and cannot see a way that it can be modelled using hibernate.

Thanks,

Julian.


Top
 Profile  
 
 Post subject: Re: Mapping Problem
PostPosted: Fri Nov 28, 2003 12:22 pm 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
arnoldj wrote:
I have two classes defined:

public class ApplicationSpecification implements Serializable {
private String id;
private String vendor;
private String name;
private String version;
private boolean rebootRequired;
private java.lang.String installationNotes;
private String description;
private boolean licenced;
}

public class ApplicationInstance extends ApplicationSpecification {
private String appInstId;
private String installationOrder;
private String notes;
private String businessUnit;
private String buildVersion;
private String language;
private String descriptor;
private boolean visible;
private String version;
}


One ApplicationSpecification is the specification for many ApplicationInstances. An ApplicationInstance is a superclass of a Specification, but they do not have the same primary id. An ApplicationInstance also has its own id.

To model this in the database I have separate tables that map exactly to the Specification and Instance tables.

The Specification table has a PK of AS_ID.
The Instance table also has a PK of AI_ID.
The Instance table also has a FK into Specification, namely AI_AS_ID.

How do I model this within the XML mapping document?

Any help would be appreciated with this as I have been working on this problem for a couple of days now and cannot see a way that it can be modelled using hibernate.

Thanks,

Julian.


You should use agregation instead of superclass i.e :
Code:
public class ApplicationInstance extends ApplicationSpecification {
private ApplicationSpecification applicationSpecification;
.....

}
[/code][/quote]


Top
 Profile  
 
 Post subject: Mapping Problem
PostPosted: Fri Nov 28, 2003 2:40 pm 
Newbie

Joined: Fri Nov 28, 2003 11:36 am
Posts: 2
I am happy to accept that we could be looking at aggregation as opposed to superclassing.

Is it possible then for the ApplicationInstance to include an ApplicationSpecification which is located in a different table? If so, how would we do that in the mappings XML file?

Thanks,

Julian.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 11:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
as you said there is one sepcification for many instances son a one to many (and many to one on the other side) seems to be approriate

_________________
Emmanuel


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.