-->
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: Criteria outer join reverse lookup where null
PostPosted: Mon Apr 09, 2012 4:34 pm 
Newbie

Joined: Mon Apr 09, 2012 4:09 pm
Posts: 1
here is my delema...
Code:
@Entity
class A{

   @Id
   long id;

   ...
}

@Entity
class Wrapper{
   
   @Id
   long id;
   
   @OneToOne
   @JoinColumns({@JoinColumn(name="a_id",referencedColumnName="id")})
   A a;
   
   ...
}


what I want in sql looks like this...

Code:
select a.*
from A a
join outer Wrapper w
on a.id = w.a_id
where w.a_id is null


Thus giving me all As that are not in B. I have successfully created it with an Exists query, but the outer join performs better. I want to create a criteria query that creates this query, but I can't seem to figure out how to define the reverse relationship, since the FK is defined on wrapper.

If I start with:
Code:
   DetachedCriteria dc = DetachedCriteria.forClass(A.class, "a");


how do I then explain the relationship to Wrapper. If I start with the wrapper class, then it is a right outer join and Criteria does not support it.

Is jql my only option?


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.