Skip to main content

EJB 3 and type converters

1 reply [Last post]
erwindl
Offline
Joined: 2006-05-17

A crucial feature in an ORM is the possibility to define in detail the conversion/formatting of data in a DB column to/from some Java property type.

E.g. for an organization with a legacy DB where dates are stored as strings with format MMYY, there should be a way to map this to a Java Date.

Can someone explain me how this is to be done with the new super-duper EJB 3.0? At least in EJB 2.x descriptors I found the optional thingy. But I can't seem to find anything in EJB 3.0 that would serve this purpose.

On the other hand, I can not imagine that the spec would be finalized without this elementary feature being in there somewhere...

Any pointers on this are very welcome!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04

Hi,

One option would be to use property based persistence where getters and setters do the conversion between a String property and a Date field. The business methods can access the field as a Date. Persistence provider will use get/set methods to load the state and synchronize it with the database.

-marina