I'm using HIbernate 3 running against DB2.
I wonder if there is a way to map an enum without creating a user type, for instance, could I use a component mapping?
I have a Java enum defined thus:
Code:
public class NormalizedRecord {
...
[b]public enum RecordType {BIRTH_INDEX_RECORD, BIRTH_MASTER_RECORD, DEATH_INDEX_RECORD, DEATH_MASTER_RECORD, FAMILY_RECORD, MARRIAGE_RECORD;[/b]
...
}
I tried the following mapping:
Code:
<class name="org.egcrc.cfr.normalized.NormalizedRecord"
table="NORM_REC"
lazy="true">
...
[b] <component name="myRecordType" class="org.egcrc.cfr.normalized.NormalizedRecord.RecordType">
<property name="value" type="string"/>
</component>[/b]
...
</class>
This compiled correctly and generated the following table definition:
create table PSD.NORM_REC (
NORM_REC_ID bigint generated by default as identity,
myCreateDate timestamp,
EVENT_DATE_IS_APPROX smallint,
EVENT_MAX_DATE timestamp,
EVENT_MIN_DATE timestamp,
EVENT_DATE timestamp,
myId integer,
value varchar(255),
mySourceId varchar(255),
primary key (NORM_REC_ID)
);
I'm just not sure if this will correctly store and retrieve the enum value.
TIA.
Larry