How to map an association with an Enum [message #530788] |
Fri, 30 April 2010 22:15 |
Chris Mathrusse Messages: 24 Registered: July 2009 |
Junior Member |
|
|
Using EclipseLink 2.0.1, JDK 6
I have a challenging situation that I have inherited. Currently this is being done with Hibernate but I've gotten the approval to migrate over to EclipseLink.
I have a table, Address
CREATE
TABLE Address
(
AddressID ID NOT NULL IDENTITY
, ... some more fields
, AddressTypeID INT
)
And table AddressType
CREATE
TABLE AddressType
(
id NOT NULL int
, name varchar(30)
, ref varchar(30)
, isActive bit
)
The challenge I am faced with is that the AddressType table is actually a view. The id field is the actual primary key in the table that the view is build upon. The ref field is a String which represents the actual type of data the view represents (Billing,Shipping,US,CustomerService,etc..). When an association is made to the Address table the AddressType.id is stored on the Address record.
What I would like to do is have a single enum class, AddressType, that represents the String values only and have a reference to the enum on the Address class. But how can I ensure during insert/update operations that the actual ID of the AddressType gets persisted? In addition, how can I map that ID from the Address table to the enum during a read operation?
All suggestions are welcome.
Thanks...
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04132 seconds