openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (JIRA)" <>
Subject [jira] Commented: (OPENJPA-905) org.apache.openjpa.persistence.kernel.TestProxies2
Date Wed, 11 Mar 2009 03:24:50 GMT


Albert Lee commented on OPENJPA-905:

The spec docuemnt that:

2.1.1 Persistent Fields and Properties
Collection-valued persistent fields and properties must be defined in terms of one of the
following collection-
valued interfaces regardless of whether the entity class otherwise adheres to the JavaBeans
method conventions noted above and whether field or property-based access is used:
java.util.Collection, java.util.Set, java.util.List[4], java.util.Map.[5]

[4] Portable applications should not expect the order of lists to be maintained across persistence
contexts unless the OrderBy construct
is used and the modifications to the list observe the specified ordering. The order is not
otherwise persistent.
[5] The implementation type may be used by the application to initialize fields or properties
before the entity is made persistent; subsequent
access must be through the interface type once the entity becomes managed (or detached).

So you are correct that the test is not quite correct. However the change has negated the
intent of the test and become not quite meaningful.
I would suggest the following:

public class ProxiesPC implements Comparable {

    @OrderBy   // <<<<<  enforce ordering of the List<String>
    private List<String> list = new ArrayList();

public class TestProxies2 extends BaseKernelTest {

    public void testChangeListOrder() {

        // re-retrieve to check ordering
        pm = getPM(false, false);
        pc = pm.find(ProxiesPC.class, _oid);

        list = pc.getList();
        assertEquals(5, list.size());
        assertEquals("val1", list.get(0));
        assertEquals("val1", list.get(1));
        assertEquals("val2", list.get(2));   //  <<<< make sure it is in the expected
order after remove/add
        assertEquals("val3", list.get(3));
        assertEquals("val3", list.get(4));

If you think this is correct, can you please erify this patch works against the databases
that had problems?

Albert Lee.

> org.apache.openjpa.persistence.kernel.TestProxies2
> --------------------------------------------------
>                 Key: OPENJPA-905
>                 URL:
>             Project: OpenJPA
>          Issue Type: Sub-task
>            Reporter: Tim McConnell
>            Assignee: Tim McConnell
>         Attachments: OPENJPA-905.patch

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message