You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by JGL <jg...@gmail.com> on 2008/05/06 03:30:43 UTC

Newbie question about to-many ordered list

Hi All,

I recently discovered Cayenne while searching for an alternative for
Hibernate.
I am very impressed with the easy & intuitive framework Cayenne provides.

While porting my current Hibernate app to Cayenne, I did run into an issue
which I'd like to seek your help:
In Hibernate, the M side of 1-M relationship can be mapped as a list, which
means it's ordered. I can specify the list-index column like this:

<class name="Item" table="ITEM">
...
<list name="bids">
<key column="ITEM_ID" not-null="true"/>
<list-index column="BID_POSITION"/>
<one-to-many class="Bid"/>
</list>
</class>

and the BID_POSITION is automatically managed by the framework.

Is there any 'list index column' equivalent in Cayenne? How can I ask the
framework to manage the list index ? or do I have to manage it by myself?

Thanks very much!!

Re: Newbie question about to-many ordered list

Posted by Andrus Adamchik <an...@objectstyle.org>.
As a side note pre-ordered relationships have been on our TODO list  
for some time. Since it is a JPA feature, it is higher priority now.

Andrus

On May 6, 2008, at 10:52 AM, Malcolm Edgar wrote:

> I tend to do this:
>
> public List<Customer> getCustomers() {
>    List<Customers> customers = super.getCustomers();
>
>    Collections.sort(customers, new
> StringComparator(Customer.NAME_PROPERTY));
>
>    return customers;
> }
>
> regards Malcolm Edgar
>
> On Tue, May 6, 2008 at 4:58 PM, Aristedes Maniatis <ar...@ish.com.au>  
> wrote:
>
>>
>> On 06/05/2008, at 11:30 AM, JGL wrote:
>>
>> Hi All,
>>>
>>> I recently discovered Cayenne while searching for an alternative for
>>> Hibernate.
>>> I am very impressed with the easy & intuitive framework Cayenne
>>> provides.
>>>
>>> While porting my current Hibernate app to Cayenne, I did run into an
>>> issue
>>> which I'd like to seek your help:
>>> In Hibernate, the M side of 1-M relationship can be mapped as a  
>>> list,
>>> which
>>> means it's ordered. I can specify the list-index column like this:
>>>
>>> <class name="Item" table="ITEM">
>>> ...
>>> <list name="bids">
>>> <key column="ITEM_ID" not-null="true"/>
>>> <list-index column="BID_POSITION"/>
>>> <one-to-many class="Bid"/>
>>> </list>
>>> </class>
>>>
>>> and the BID_POSITION is automatically managed by the framework.
>>>
>>> Is there any 'list index column' equivalent in Cayenne? How can I  
>>> ask
>>> the
>>> framework to manage the list index ? or do I have to manage it by
>>> myself?
>>>
>>> Thanks very much!!
>>>
>>
>>
>> Well, you can order the results easily enough once you fetch them  
>> into a
>> list:
>>
>> http://cayenne.apache.org/doc/using-orderings.html
>>
>> In Cayenne 3 you can also fetch the results into a Map if that  
>> helps what
>> you are trying to do.
>>
>>
>> Ari Maniatis
>>
>>
>>
>> -------------------------->
>> ish
>> http://www.ish.com.au
>> Level 1, 30 Wilson Street Newtown 2042 Australia
>> phone +61 2 9550 5001   fax +61 2 9550 4001
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>>
>>


Re: Newbie question about to-many ordered list

Posted by Malcolm Edgar <ma...@gmail.com>.
I tend to do this:

public List<Customer> getCustomers() {
    List<Customers> customers = super.getCustomers();

    Collections.sort(customers, new
StringComparator(Customer.NAME_PROPERTY));

    return customers;
}

regards Malcolm Edgar

On Tue, May 6, 2008 at 4:58 PM, Aristedes Maniatis <ar...@ish.com.au> wrote:

>
> On 06/05/2008, at 11:30 AM, JGL wrote:
>
>  Hi All,
> >
> > I recently discovered Cayenne while searching for an alternative for
> > Hibernate.
> > I am very impressed with the easy & intuitive framework Cayenne
> > provides.
> >
> > While porting my current Hibernate app to Cayenne, I did run into an
> > issue
> > which I'd like to seek your help:
> > In Hibernate, the M side of 1-M relationship can be mapped as a list,
> > which
> > means it's ordered. I can specify the list-index column like this:
> >
> > <class name="Item" table="ITEM">
> > ...
> > <list name="bids">
> > <key column="ITEM_ID" not-null="true"/>
> > <list-index column="BID_POSITION"/>
> > <one-to-many class="Bid"/>
> > </list>
> > </class>
> >
> > and the BID_POSITION is automatically managed by the framework.
> >
> > Is there any 'list index column' equivalent in Cayenne? How can I ask
> > the
> > framework to manage the list index ? or do I have to manage it by
> > myself?
> >
> > Thanks very much!!
> >
>
>
> Well, you can order the results easily enough once you fetch them into a
> list:
>
> http://cayenne.apache.org/doc/using-orderings.html
>
> In Cayenne 3 you can also fetch the results into a Map if that helps what
> you are trying to do.
>
>
> Ari Maniatis
>
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>
>

Re: Newbie question about to-many ordered list

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 06/05/2008, at 11:30 AM, JGL wrote:

> Hi All,
>
> I recently discovered Cayenne while searching for an alternative for
> Hibernate.
> I am very impressed with the easy & intuitive framework Cayenne  
> provides.
>
> While porting my current Hibernate app to Cayenne, I did run into an  
> issue
> which I'd like to seek your help:
> In Hibernate, the M side of 1-M relationship can be mapped as a  
> list, which
> means it's ordered. I can specify the list-index column like this:
>
> <class name="Item" table="ITEM">
> ...
> <list name="bids">
> <key column="ITEM_ID" not-null="true"/>
> <list-index column="BID_POSITION"/>
> <one-to-many class="Bid"/>
> </list>
> </class>
>
> and the BID_POSITION is automatically managed by the framework.
>
> Is there any 'list index column' equivalent in Cayenne? How can I  
> ask the
> framework to manage the list index ? or do I have to manage it by  
> myself?
>
> Thanks very much!!


Well, you can order the results easily enough once you fetch them into  
a list:

http://cayenne.apache.org/doc/using-orderings.html

In Cayenne 3 you can also fetch the results into a Map if that helps  
what you are trying to do.


Ari Maniatis



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A