-->
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.  [ 2 posts ] 
Author Message
 Post subject: Joint two Tables without being referenced by the Database
PostPosted: Wed Aug 13, 2008 5:18 am 
Newbie

Joined: Wed Aug 13, 2008 4:35 am
Posts: 2
Hibernate version:3.3.0.CR2

Name and version of the database you are using:Oracle Database 10g Enterprise Edition Release 10.2.0.3.0


Hi I have following Problem:

I have 2 Tables:

Table Recht:
<Name> <Type> <PrimaryKey>
UIID VARCHAR2(10 CHAR) 1
RECHTID VARCHAR2(10 CHAR) 2
MODULID VARCHAR2(20 CHAR) 3
RECHT NUMBER(9,0) NO

Table Gruppe:
<Name> <Type> <PrimaryKey>
GRUPPEID VARCHAR2(10 CHAR) 1
GRPTEXT VARCHAR2(50 CHAR) NO
UIID VARCHAR2(10 CHAR) NO


These two Tables are standalone Tables that means no referencing is set at all in the Database (no ForeignKey).

Is it possible to join this tables with the UIID like with this sql command:
select * from gruppe inner join recht on gruppe.uiid= recht.uiid ??


I've tried to map this tables in the gruppe.hbm.xml mapping file:

<hibernate-mapping>
<class name="beans.Gruppe" table="GRUPPE" >
<id name="gruppeid" type="java.lang.String" column="GRUPPEID" length="10">
</id>
<property name="uiid" type="java.lang.String" column="UIID" length="10" />
<property name="grptext" type="java.lang.String" column="GRPTEXT" length="50" />

<set name="rechte" cascade="all" table="Recht">
<key column="UIID"/>
<one-to-many class="beans.Recht" />
</set>


But it doesn't work and the set is always empty.


The set with the name rechte is defined in the Gruppe.java Bean Class with:
Code:
private java.util.Set rechte = new java.util.HashSet();


So as a summary:
I want to get all the Rechte entries that belong to a group entry referenced by the uiid. So I want to join two tables that aren't referenced in any way by the database.
I cannot change the database structure like adding a constraint or something.

Thank you very much for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 5:45 am 
Newbie

Joined: Wed Aug 13, 2008 4:35 am
Posts: 2
I now looked at the problem from a complete different side and found out that a simple property-ref="uiid" in the set mapping of gruppe.hbm.xml solves the problem because hibernate joins to the primary key of the gruppe table and this primary key isn't the uiid.
So the admin can delete my post or let it be for others that are also less concentrated like me :-(

Nevertheless thank you very much!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.