-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping data from one table to another with SQL logic
PostPosted: Mon Jun 27, 2005 12:02 pm 
Beginner
Beginner

Joined: Thu Mar 31, 2005 5:59 pm
Posts: 34
Hibernate version:
3.0

I am pretty new to Hibernate and thought I had a lot of my way figured around, but I haven't tried to do anything like this before, so I'm asking for help.

Here's my problem. First of all this is legacy data, so I have no control over the data. I have one table with some data in it that I want to get (no problem doing that in Hibernate). One of the columns (lets call it number), sort of maps to another table with another piece of data I need.

For simplicity's sake, I'll put some sample data:

Code:
TABLE_ONE

NUMBER   OTHER_DATA   ANOTHER_DATA
------   ----------   ------------
010010   something    123 lois ln
02483    else         342 main st
064939   another      298 that way


TABLE_TWO

NO    DATA_I_NEED
---   -----------
010   something here
02    another thing
064   something else



How it maps: substr(NUMBER, 1, length(NUMBER)-3) = NO

The piece of data I need associated with TABLE_ONE (in the object TableOne) is DATA_I_NEED. NUMBER is also the primary key of TABLE_ONE (which I need as is in my TableOne object as well).

Anyways, I keep looking at all the mapping file information and I don't seem to get how to do this.

Thanks in advance for any help!
Susan[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.