-->
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: sqlResultSetMapping problem with self join
PostPosted: Sun Sep 11, 2005 4:20 am 
Newbie

Joined: Sun Aug 14, 2005 5:29 pm
Posts: 6
Location: zurich switzerland
I have a problem with @SqlResultSetMapping using a native SQL self join:
I get 2 same objects!

ClassA snippet:
Code:
SqlResultSetMapping(name="PairResults", entities={
  @EntityResult(name="com.ideartis.jee.A"),
  @EntityResult(name="com.ideartis.jee.A")})
public class A implements Serializable {
...


SQL snippet:
Code:
select a1.*, a2.* from
  (select * from a ..) as a1,
  (select * from a ..) as a2
where ..


This SQL is a self join with from-clause subqueries. The result is a list of pairs. The elements of a pair are of the same type (class A).
From the semantic of the search I expect the 2 elements to be always different instances. The SQL query from a DB client-GUI shows that this is true (they are 2 different rows).

But when I run the EJB 3.0 SQL-result-to-object mapping the elements are the same (the first element is also at the second position!).

What have I done wrong with the mapping?

Regards
Alain Hsiung


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You have to define the field mapping explicitly since the second on does not respect the default values.

_________________
Emmanuel


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.