openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <michael.d.d...@gmail.com>
Subject Re: ordered Lists, with list position in join table
Date Fri, 24 Oct 2008 21:34:47 GMT
Glad to help. I think it will work, I didn't use @JoinTable in my test
though.

-mike

On Fri, Oct 24, 2008 at 3:48 PM, Fernando Padilla <fern@alum.mit.edu> wrote:

> nice :)
>
> so I use @ManyToMany, and still use the @JoinTable, but simply add the
> @OrderColumn instead of the @OrderBy?
>
>
> Michael Dick wrote:
>
>> In that case the OpenJPA OrderColumn annotation should work.
>>
>> import org.apache.openjpa.persistence.jdbc.OrderColumn;
>>
>> @Entity
>> public class FLeague extends HBaseIdCreateTime {
>> ....
>>      @ManyToMany
>>      @OrderColumn(name="DRAFTORDER_ORDER")
>>      private List<FTeam> draftOrder;
>> ....
>> }
>>
>> hth
>>
>> -mike
>>
>> On Fri, Oct 24, 2008 at 2:11 PM, Fernando Padilla <fern@alum.mit.edu>
>> wrote:
>>
>>  :( it's not.
>>>
>>> the sort column lives purely in the relational join table, and is not
>>> associated with any fields in the target entity.
>>>
>>>
>>>
>>>
>>> Michael Dick wrote:
>>>
>>>  Hi,
>>>>
>>>> If the sort column is a mapped field in the target entity you can use
>>>> "vanilla" JPA. Something like this should work for you  :
>>>>
>>>> @Entity
>>>> public class FLeague extends HBaseIdCreateTime {
>>>> ....
>>>>      @ManyToMany
>>>>      @OrderBy("${fieldName} ASC")
>>>>      private List<FTeam> draftOrder;
>>>> ....
>>>> }
>>>>
>>>> Replace ${fieldName} with the name of the field in the target entity and
>>>> you
>>>> should be good to go. If you don't specify a fieldname we'll sort by
>>>> primary
>>>> key.
>>>>
>>>> Regards,
>>>> -mike
>>>>
>>>>
>>>> On Fri, Oct 24, 2008 at 12:26 PM, Fernando Padilla <fern@alum.mit.edu
>>>>
>>>>> wrote:
>>>>>
>>>>  So, again, I'm trying to port from old JDO to new JPA :)  And I'm
>>>> trying
>>>>
>>>>> to
>>>>> map a List object, where the relational table is storing the position
>>>>> of
>>>>> each element.  It looks like standard JPA doesn't want to support this,
>>>>> but
>>>>> I was wondering if OpenJPA had this as an option in some way...:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> And I have this sort of relational join table.
>>>>>
>>>>> mysql> desc FLEAG_DRAFTORDER;
>>>>> +------------------+------------+------+-----+---------+-------+
>>>>> | Field            | Type       | Null | Key | Default | Extra |
>>>>> +------------------+------------+------+-----+---------+-------+
>>>>> | DRAFTORDER_JDOID | bigint(20) | YES  | MUL | NULL    |       |
>>>>> | DRAFTORDER_ORDER | int(11)    | YES  |     | NULL    |       |
>>>>> | JDOID            | bigint(20) | YES  | MUL | NULL    |       |
>>>>> +------------------+------------+------+-----+---------+-------+
>>>>> JDOID -> FLEAGUE
>>>>> DRAFTORDER_JDOID -> FTEAM
>>>>> DRAFTORDER_ORDER -> LIST_INDEX_POSITION
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> The owning class has a field:
>>>>>
>>>>> @Entity
>>>>> public class FLeague extends HBaseIdCreateTime {
>>>>> ....
>>>>>      @ManyToMany
>>>>>      private List<FTeam> draftOrder;
>>>>> ....
>>>>> }
>>>>>
>>>>>
>>>>> @Entity
>>>>> public class FTeam extends HBaseIdCreateTime {
>>>>> ....
>>>>> }
>>>>>
>>>>>
>>>>>
>>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message