Enhancement 92 : ENHANCEMENT: Add In Sub Query expression
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
1.1.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
19/03/2009
Updated 
19/03/2009
Type 
Enhancement
 
Attachments 
No attachments

See forum http://www.avaje.org/topic-128.html

An example:

Query<Product> subQuery = 
	Ebean.createQuery(Product.class)
		.select("sku")
		.where().idEq(4).query();

List<MinCustomer> list = Ebean.find(MinCustomer.class)
	.where().in("name", subQuery)
	.findList();
 
Rob 19 Mar 12:03
Produces SQL...
select c.id, c.name, c.notes 
from o_customer c 
where  (c.name) in (select p.sku  from o_product p  where p.id = ?  )

Rob 19 Mar 12:04
Credit

Credit goes to Mario for this enhancement and the code.

Code to support this is now in HEAD.

Rob 19 Mar 12:04
Committed to HEAD

Code to support this is now in HEAD.

woResponse

Upload a file