Skip to main content

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 AtienzarFriend
Messages: 6
Registered: April 2010
Junior Member

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

property3 --> this is a set (oneToMany)

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,

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 SutherlandFriend
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: Tue Jun 19 10:59:07 GMT 2018

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

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

Back to the top