DataNucleus - Products
  History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: NUCRDBMS-50
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Erik Bengtson
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus RDBMS

Support arbitrary enum values to be persisted

Created: 20/Apr/07 09:17 PM   Updated: 27/Aug/08 08:23 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
Enum usage is normally a combination of name and ordinal values. Currently JPOX supports persisting the name or ordinal values, but should be allowed to persist arbitrary values. See the example:

public enum Test {
    RED(1), BLUE(5);
    
    private final int value;
    
    Test(int v)
    {
        this.value = v;
    }
    
    public final int getValue()
    {
        return this.value;
    }
    
    public final static Enum getEnum(int i)
    {
        switch(i)
        {
            case 1: return Test.RED;
            case 5: return Test.BLUE;
        }
        return null;
    }
}


<jdo>
    <package name="org.jpox.samples.jdo.enums">
        <class name="Palette">
            <field name="color" persistence-modifier="persistent" serialized="false">
             <column>
<extension vendor-name="jpox" key="enum-persistence-value-getter" value="getValue"/>
<extension vendor-name="jpox" key="enum-enum-value-getter" value="getEnum"/>
             </column>
            </field>
        </class>
    </package>
</jdo>

enum-enum-value-getter is the getter name for a static method that returns the Enum instance for the corresponding value.
enum-persistence-value-getter is the getter name for an instance method that returns the value to be persisted

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson - 24/Apr/07 11:28 AM
Moving to beta-3 since beta-2 release is tomorrow.

Andy Jefferson - 02/Jul/07 06:27 AM
Moved to next release since no comment on the status of this

Andy Jefferson - 08/Jan/08 05:30 PM
Not part of JDO2.1/JPA1 so moving to JPOX 1.3