2

I have to read dates from a database using JPA. I'm using EclipseLink and MySQL. The date is stored in the database as varchar(10) in the format YYYY-MM-DD. It's not possible changing the database column type. Is there a way to map this column to some dates type (DATE, CALENDAR)? Is it possible to force convertion?

user1052004
  • 93
  • 2
  • 6

1 Answers1

1

With EclipseLink you can use a Converter.

See, http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_converter.htm#CHDEHJEB

A simple @TypeConverter may work, otherwise you can create your own Converter.

James
  • 17,965
  • 11
  • 91
  • 146