-->
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: mapping columns
PostPosted: Tue Jun 26, 2007 7:10 pm 
Beginner
Beginner

Joined: Mon Jun 25, 2007 11:57 pm
Posts: 28
Hi,

I'm working on mapping an existing legacy database which has tables spread across multiple schemas.

Basically the problem is i want to create a mapping from one table in Schema A to another table in Schema B. But the columns to be mapped are not constrained to each other in any way (FK/PK) and are not the PK of either table.

It's required that the mapping be a one-to-many relationship from Table A to Table B, i.e. contain a set of Table B records.

Maybe worth mentioning that this column is a foreign key in Table B to another table (Table C).

How can this relationship be expressed in Hibernate?
Do i have to use HQL to express this relationship or can it be done using Hibernate's xml elements? Or do i need to add constraints to the db?

Thanks for any help,
John

Hibernate version: 3.2.4.sp1

Name and version of the database you are using: Oracle 10g


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 2:56 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
In the mapping file use the schema attribute as shown below.

Code:
<hibernate-mapping>
    <class name="YourClassName" table="YourTableName" schema="YourSchemaName">


Hope this helps.

Nikhil


Top
 Profile  
 
 Post subject: mapping columns
PostPosted: Thu Jun 28, 2007 6:40 pm 
Beginner
Beginner

Joined: Mon Jun 25, 2007 11:57 pm
Posts: 28
Thanks for that. Got it sussed with combination of schema="" and using property-ref attribute on the key element in order to reference the correct column.

Cheers,
John


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.