DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-437
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Erik Bengtson
Votes: 2
Watchers: 2
Operations

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

Support arbitrary enum values to be persisted

Created: 20/Apr/07 09:17 PM   Updated: 11/Jun/10 01:38 PM   Resolved: 04/Jun/10 04:18 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.0.release


 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

Andy Jefferson added a comment - 24/Apr/07 11:28 AM
Moving to beta-3 since beta-2 release is tomorrow.

Andy Jefferson made changes - 24/Apr/07 11:28 AM
Field Original Value New Value
Fix Version/s 1.2.0-beta-3 [ 10234 ]
Fix Version/s 1.2.0-beta-2 [ 10202 ]
Andy Jefferson added a comment - 02/Jul/07 06:27 AM
Moved to next release since no comment on the status of this

Andy Jefferson made changes - 02/Jul/07 06:27 AM
Fix Version/s 1.2.0-rc-1 [ 10253 ]
Fix Version/s 1.2.0-beta-3 [ 10234 ]
Andy Jefferson made changes - 10/Sep/07 05:37 PM
Fix Version/s 1.2.0-rc-1 [ 10273 ]
Fix Version/s 1.2.0-beta-4 [ 10253 ]
Andy Jefferson made changes - 07/Dec/07 10:54 AM
Fix Version/s 1.2.0 [ 10121 ]
Fix Version/s 1.2.0-rc-1 [ 10273 ]
Andy Jefferson added a comment - 08/Jan/08 05:30 PM
Not part of JDO2.1/JPA1 so moving to JPOX 1.3

Andy Jefferson made changes - 08/Jan/08 05:30 PM
Fix Version/s 1.3.0 [ 10264 ]
Fix Version/s 1.2.0 [ 10121 ]
Andy Jefferson made changes - 29/May/08 08:27 AM
Fix Version/s 1.2.3 [ 10264 ]
Andy Jefferson made changes - 15/Jul/08 08:34 AM
Project JPOX Java5 [ 10030 ] DataNucleus Java5 [ 10161 ]
Key JAVAFIVEPLUGIN-51 NUCJAVAFIVE-19
Affects Version/s 1.2.0-beta-1 [ 10181 ]
Andy Jefferson made changes - 29/Jul/08 02:52 PM
Assignee Erik Bengtson [ erik ]
Andy Jefferson made changes - 27/Aug/08 08:23 AM
Project DataNucleus Java5 [ 10161 ] DataNucleus RDBMS [ 10144 ]
Key NUCJAVAFIVE-19 NUCRDBMS-50
Andy Jefferson made changes - 03/Aug/09 08:29 PM
Priority Major [ 3 ] Minor [ 4 ]
Andy Jefferson made changes - 26/Dec/09 12:53 PM
Project DataNucleus RDBMS [ 10144 ] DataNucleus Core [ 10143 ]
Key NUCRDBMS-50 NUCCORE-437
Andy Jefferson added a comment - 04/Jun/10 04:18 PM
Use of extensions "enum-value-getter" (to get the value from an Enum) and "enum-getter-by-value" (to get the Enum from the value) are supported in SVN trunk. Extensions should be specified on field (1-1 relation) or on element, key, value (1-N relation).

Andy Jefferson made changes - 04/Jun/10 04:18 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 2.1.0.release [ 10836 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 11/Jun/10 01:38 PM
Status Resolved [ 5 ] Closed [ 6 ]