-->
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: Advanced join!!! How?
PostPosted: Thu Apr 26, 2007 7:44 am 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
Hello,

so. here is my problem:

I have 2 tables
Table A
{
ID integer,
column1 integer
column2 integer
.
.}

Table B{
ID integer,
ID_fromTabA integer,
PROP_TYPE integer,
PROP_STRING,
.
.}

And my class:
Code:
class ObjectWithProps{
Inteder id;
String prop1;
String prop2;
...
String propN;
}


I know that for object with id=1 in table A
must be properties in table B in form

Code:
[b]for prop1:[/b]
ID_fromTabA = 1,
PROP_TYPE = 1,
PROP_STRING = "aaaaaaa"

[b]for prop2:[/b]
ID_fromTabA = 1,
PROP_TYPE = 2,
PROP_STRING = "bbbb"


so in map xml i created this:

<class name="ObjectWithProps" table="tableA"
.
.
<property name="prop1" type="string" column="tableB" update="false" insert="false"
formula= "(SELECT tableB.pro_string FROM tableB WHERE tableB.id_fromTabA=id AND prop_type=1)"
/>
<property name="prop2" type="string" column="tableB" update="false" insert="false"
formula= "(SELECT tableB.pro_string FROM tableB WHERE tableB.id_fromTabA=id AND prop_type=2)"
/>

and this works, but SQL generated from Hibernate is in form:

SELECT ...... (SELCET SELECT tableB.pro_string FROM tableB WHERE tableB.id_fromTabA=id AND prop_type=1), SELCET SELECT tableB.pro_string FROM tableB WHERE tableB.id_fromTabA=id AND prop_type=2)
FROM TableA
WHERE id=1

Plese tell me how to use
<join ../>
and construct same result but SQL to be with INNER JOIN

Thank you.


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.