Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Is it possible to return a Collection inside a multiselect (CriteriaBuilder)
Is it possible to return a Collection inside a multiselect (CriteriaBuilder) [message #525473] Tue, 06 April 2010 16:43 Go to next message
Marcial Atienzar is currently offline Marcial Atienzar
Messages: 6
Registered: April 2010
Junior Member
Hi,

How can I return certain properties of an entity. Is to say, I've an entity with:

property1
property2
property3 --> this is a set (oneToMany)
property4
...
property40

And I need only to return property1,property2 and property 3

Is it possible? How can I do this? Can I do this with sql o jql?

Lot of thanks,

Marcial
Re: Is it possible to return a Collection inside a multiselect (CriteriaBuilder) [message #527035 is a reply to message #525473] Tue, 13 April 2010 19:14 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I think you can just select the 1-m the same as any other attribute.

In JPQL you could do,

Select e.property1, e.property2, e,property3 from Entity e

The equivalent should work with the Criteria API, what code do you have so far?

This will return you a List<Object[]> where the Object[] has property1, property2, and each of the property3 (one Object[]/row for each property3 instance).

In EclipseLink you could also just do a normal query and use a fetch-group query hint to only select the desired attributes for the object.


James : Wiki : Book : Blog : Twitter
Previous Topic:How can I add extra join conditions with left joins
Next Topic:Class loading problem on new() in JPQL
Goto Forum:
  


Current Time: Sun Oct 26 08:45:57 GMT 2014

Powered by FUDForum. Page generated in 0.01510 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software