-->
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: SQLQuery join tables problem
PostPosted: Mon Feb 06, 2006 11:57 am 
Newbie

Joined: Thu Jan 26, 2006 12:25 pm
Posts: 3
Hi

I have a problem like this. Can anyone help me?

Table1
id, code1, code2
========================
Table2
id, code3, code4
========================
class Table1
{
private Long id;
private Long code1;
private Long code2;
private Long code3
}

the relationship between these tables is one-to-one(code1 from Table1=id from Table2)
========================

in mapping xml for Table1

...
<property "code1"/>
<property "code2"/>
....
========================

query

List list =
session.createSQLQuery("select " +
"T1.id as {Table1.id} , " +
"T1.code1 as {Table1.code1} , " +
"T1.code2 as {Table1.code2} , " +
"T2.code3 ????} "

" from Table1 T1 right outer join Table2 T2 on T1.code1 = T2.id " +

" where T1.id = 1")
.addEntity("Table1", Table1.class).list();

i want to get data form Table2 without mapping fields code3, code4 from Table2.
Can i do this(hibernate want mapping for code3, code4 but they are in different table not in Table1)?
If i can't - any idea how can i resolve my problem?

Best regards,
cool_boy1


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.