-->
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: One-2-one using more than 1 column
PostPosted: Tue Sep 14, 2010 6:19 am 
Newbie

Joined: Tue Sep 14, 2010 6:04 am
Posts: 5
Hi,

I am just a newbie in Hibernate but I have to face an old-ugly DB. Ugly because when we join tables, we always need to trim of fill in some spaces, even add some custom text to PK or FK.

Here is the problem: An ENTITY (have standard id = id) have corresponding EMPLOYEE (with composite key of Emp_code, Some_code) following the criteria below:

ENTITY.Some_code= trim (EMPLOYEE.Some_code)
ENTITY.other_code = trim (EMPLOYEE.Emp_code)

What I have to achieve is: entity.getEmployee return an Employee (or even better employee.getEntity() return Entity) using the mapping file ENTITY.hbm.xml, without using additional DAO function . I have tried many ways but always failed:
- one-2-one: From ENTITY
- many-2-one: : From ENTITY
- using formula: I picked up somes on the net but didn't find the proper one.
- using loader and sql-query: but it is only available for set, not for one-2-one, property, many-2-one.....

Pls give me some hints or better with some samples.

Thank you


Last edited by phuyem on Tue Sep 14, 2010 10:48 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: One-2-one using more than 1 column
PostPosted: Tue Sep 14, 2010 8:20 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Sorry could u explain in better way , i did not understand

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: One-2-one using more than 1 column
PostPosted: Tue Sep 14, 2010 10:44 am 
Newbie

Joined: Tue Sep 14, 2010 6:04 am
Posts: 5
Haha. Sorry for my bad English. Here you are:

1. From 1 ENTITY, I want to get one EMPLOYE using ENTITY.hbm.xml and Entity.getEmploye()
2. The relation ship:

ENTITY.Some_code= trim (EMPLOYEE.Some_code)
ENTITY.other_code = trim (EMPLOYEE.Emp_code)

where Emp_code and Some_code make composite key of EMPLOYEE
Some_code and other_code are just normal column of ENTITY.

Hope that is clearer now :)


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.