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 question
PostPosted: Tue Sep 07, 2004 11:47 am 
Newbie

Joined: Mon May 03, 2004 1:08 am
Posts: 18
Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

Debug level Hibernate log excerpt:


How do I map the following?
In my current system I have a class called Link which simply has two attributes (id,name).
id is the primary key in the respective table.
name is what gets displayed .

I reuse the Link concept anytime I need to reference an other object.
eg- link to User
link to Account

My UI tier knows how to interpret this data structure.

I have tried to simplify by omitting everything we dont need.


public class Account {

Link user ;
Link bank;
String no
Double balance.
..
}


public class Link {
String id
String desc
}


SQL-
Select user.id, user.name, bank.id, bank.name ...
from account ,user, bank
where ...

public void constructAccount{
Account acc = new Accout();
acc.setUser( new Link(results.getString(user.id),
results.getString(user.name))
)
acc.setBank( new Link(results.getString(bank.id),
results.getString(bank.name))
)

}


So my question is how do I map this Link concept? The column name changes wrt the Link I need.
I am trying to use Hibernate without changing the existing datastructure and data model so that I can isolate the changes to the DAO tier.
thanks a lot for any input or pointers


Top
 Profile  
 
 Post subject: Is this possible?
PostPosted: Wed Sep 08, 2004 9:12 am 
Newbie

Joined: Mon May 03, 2004 1:08 am
Posts: 18
I coudl not figure out how to get this done? Anyone can you get me pointed in the right direction
thx


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 6:54 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
you need to have an Id in the Account object. what is the primary key for the object?


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.