You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Mariusz Lipinski <ma...@interia.pl> on 2007/06/04 12:01:58 UTC

How to use @OrderColumn values in SELECT

Hi,

OpenJPA adds an extension to JPA spec allowing to persist List order in
additional database table column. It goes like this:

   @OrderColumn(name="ORD")
   private List<Request> requests;

But is there a way I could use this value (value of ORD column) in SELECT
then? Eg. I would like to select all the requests for specific set of people
but only those that are on the first position on their requests list.
-- 
View this message in context: http://www.nabble.com/How-to-use-%40OrderColumn-values-in-SELECT-tf3864133.html#a10946843
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: How to use @OrderColumn values in SELECT

Posted by Patrick Linskey <pl...@gmail.com>.
> But is there a way I could use this value (value of ORD column) in SELECT
> then? Eg. I would like to select all the requests for specific set of people
> but only those that are on the first position on their requests list.

Not directly, and this is by design. The JPA @OrderBy annotation is
defined in terms of your object model; the OpenJPA @OrderColumn
annotation is defined in terms of the relational model for situations
when you want to order by a column that is not mapped to a field in
the object.

However, with OpenJPA's partial-key joins, you could always create a
'firstRequest' relation, and then select that data in your query. See
http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_mapping_notes_nonstdjoins
for details about partial-key joins.

-Patrick

On 6/4/07, Mariusz Lipinski <ma...@interia.pl> wrote:
>
> Hi,
>
> OpenJPA adds an extension to JPA spec allowing to persist List order in
> additional database table column. It goes like this:
>
>    @OrderColumn(name="ORD")
>    private List<Request> requests;
>
> But is there a way I could use this value (value of ORD column) in SELECT
> then? Eg. I would like to select all the requests for specific set of people
> but only those that are on the first position on their requests list.
> --
> View this message in context: http://www.nabble.com/How-to-use-%40OrderColumn-values-in-SELECT-tf3864133.html#a10946843
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
>
>


-- 
Patrick Linskey
202 669 5907