-->
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: Parameterized Custom Foreign Key - many-to-one mapping
PostPosted: Mon Apr 11, 2005 1:41 pm 
Newbie

Joined: Mon Apr 11, 2005 1:14 pm
Posts: 7
Location: Charlotte, NC
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:xml

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

Full stack trace of any exception that occurs:N/A

Name and version of the database you are using:Oracle 9i

The generated SQL (show_sql=true):N/A

Debug level Hibernate log excerpt:N/A


I have a complex foreign key that does not map to the primary key of the foreign table. Additionally, it requires a condition on another column. I would like this to be an object mapping, but can't seem to get the mapping to work. I am at a loss as to how to map this ( if it is possible).

Tables
Code:
Lookup_Table
id - pk
type
code
description

My_Table
id - pk
lookup_table_code


where clause example:
Code:
select * from my_table m, lookup_table l
where m.lookup_table_code = l.code and l.type = 'xxx'



Additionally, the pojo MyTable class looks as follows:
Code:
public class MyTable {
   private long id
   private LookupItem lookupType;



mapping:
Code:
<many-to-one name="type"  class="com.wachovia.retail.valueobjects.LookupItem" foreign-key="char_mod">      
</many-to-one>


I am uncertain as to how to get the parameter l.type = 'xxx' into the mapping... the <formula> tag doesn't seem to work.

Thanks,
Michael


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.