-->
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.  [ 2 posts ] 
Author Message
 Post subject: Subclass and One-to-One relationship
PostPosted: Fri May 27, 2005 5:27 pm 
Newbie

Joined: Thu May 05, 2005 2:34 pm
Posts: 4
Location: Charlotte,NC
Hi,

I am trying to persist the following objects in the listed tables.
To specify in the .hbb.xml, How do I specify this?
Eithe one Mapping XML or Two XML Mapping?
If I use <sub-class>, Can I define the TradeTypeA class persistence mapping in a different xml file?

Please help me out here.

Thanks,
Idhaya


CREATE TABLE TradeHeader (
tradeId int NOT NULL,
status char(10) NOT NULL,
inTime datetime NOT NULL,
operator char(10) NOT NULL,
)


ALTER TABLE TradeHeader ADD CONSTRAINT PK_TradeHeader
PRIMARY KEY (tradeId)


CREATE TABLE TradeTypeA (
tradeId int NOT NULL,
valueDate datetime NOT NULL,
dealDate datetime NOT NULL,
book char(5) NOT NULL,
)

ALTER TABLE TradeTypeA ADD CONSTRAINT PK_TradeTypeA
PRIMARY KEY (tradeId)
GO
ALTER TABLE TradeTypeA ADD CONSTRAINT FK_TradeTypeA_TradeHeader
FOREIGN KEY (tradeId) references TradeHeader(tradeId)
GO


public class TradeHeader implements java.io.Serializable {


private java.lang.Integer TradeId;
private java.lang.String Status;
private java.util.Date InTime;
private java.lang.String Operator;
}

public class TradeTypeA extends TradeHeader implements java.io.Serializable {

private java.util.Date ValueDate;
private java.util.Date DealDate;
private java.lang.Character Book;
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 6:05 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
You can defined your mapping in multiple mapping files, as long as they are all referenced through your configuration file (hibernate.cfg.xml).

As far as inheritance is concerned, a subclass is declared within it's parent <class> element. So you would have to do it in the same mapping file.

_________________
Vincent Giguère
J2EE Developer


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