Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Converter is not called on load operation
Converter is not called on load operation [message #903046] Tue, 21 August 2012 17:53 Go to next message
Lars Drießnack is currently offline Lars DrießnackFriend
Messages: 9
Registered: August 2012
Junior Member

I'm trying to generate a value of an entity while persisting it (insertedAt Date). The converter works fine and generates the value but when I'm loading the entity the value of insertedAt is allways null. On database the value exists.

I debugged everything and it just seems that the converter is not called while the process of loading something from the database. The whole field is not loaded.

public abstract class BaseObject implements Serializable {

private static final long serialVersionUID = -1387727537841488003L;


@Column(nullable = false)
@Converter(name = "insertedAtConverter", converterClass =           ....InsertedAtConverter.class)
private DateTime insertedAt;


public class InsertedAtConverter implements Converter {

private static Logger logger = Logger.getLogger(InsertedAtConverter.class);

private static final long serialVersionUID = -5174445313301568350L;

public Object convertObjectValueToDataValue(Object objectValue, Session  arg1) {
logger.debug("InsertedAtConverter called.");

if (objectValue == null) {
} else if (objectValue instanceof DateTime) {
	return ((DateTime) objectValue).toString();
} else
	throw new IllegalStateException("Converstion exception, value is not of org.joda.time.DateTime type or null.");

public Object convertDataValueToObjectValue(Object dataValue, Session arg1) {
logger.debug("DateTimeConverter called.");

if (dataValue instanceof String)
     return DateTime.parse((String) dataValue);
 throw new IllegalStateException("Converstion exception, value is not of String type.");

public void initialize(DatabaseMapping arg0, Session arg1) {


public boolean isMutable() {
	return false;

Any suggestions?

kind regars,
Re: Converter is not called on load operation [message #905010 is a reply to message #903046] Wed, 29 August 2012 14:52 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This is not what converters are for, you are not converting a value, you are initializing it. Instead initialize it in your model/application or using a PrePersist event.

James : Wiki : Book : Blog : Twitter
Previous Topic:Dynamic EclipseLink JPA Clarification
Next Topic:JPA-RS hooks and/or HATEOAS?
Goto Forum:

Current Time: Wed Sep 23 02:12:59 GMT 2020

Powered by FUDForum. Page generated in 0.02212 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top