Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA 2.1 @Converter bug?
JPA 2.1 @Converter bug? [message #1077070] Thu, 01 August 2013 07:58 Go to next message
Phill Ashworth is currently offline Phill Ashworth
Messages: 5
Registered: August 2012
Junior Member
I've got a JPA 2.1 javax.persistence.Converter as below to convert Joda DateTime to/from database "timestamp" column, when converting to entity I get an exception:
An exception occurred while calling convertToEntityAttribute on converter class com.myapp.orm.JodaDateTimeConverter with value 18/07/13 07:11


I can't see any problems with the converter code, any ideas what's going wrong here?

@Converter(autoApply = true)
public class JodaDateTimeConverter implements AttributeConverter<DateTime, Timestamp> {

    @Override
    public Timestamp convertToDatabaseColumn(DateTime attribute) {
        if (attribute == null) {
            return null;
        } else {
            return new Timestamp(attribute.getMillis());
        }
    }

    @Override
    public DateTime convertToEntityAttribute(Timestamp dbData) {
        if (dbData == null) {
            return null;
        } else {
            return new DateTime(dbData.getTime());
        }
    }
}


Caused by: javax.persistence.PersistenceException: An exception occurred while calling convertToEntityAttribute on converter class com.myapp.orm.JodaDateTimeConverter with value 18/07/13 07:11
	at org.eclipse.persistence.internal.jpa.metadata.converters.ConverterClass.convertDataValueToObjectValue(ConverterClass.java:77) ~[org.eclipse.persistence.jpa.jar:na]
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getObjectValue(AbstractDirectMapping.java:614) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.valueFromRow(AbstractDirectMapping.java:1215) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1454) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:455) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:862) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:777) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:730) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:629) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:587) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:571) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:782) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:848) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:490) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744) ~[org.eclipse.persistence.core.jar:na]
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258) ~[org.eclipse.persistence.jpa.jar:na]
	at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:516) ~[org.eclipse.persistence.jpa.jar:na]
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400) ~[org.eclipse.persistence.jpa.jar:na]
	at com.moovright.business.agency.service.AgencyService.findMoovRight(AgencyService.java:22) ~[main/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081) ~[na:na]
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153) ~[na:na]
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695) ~[ejb-container.jar:na]
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) ~[ejb-container.jar:na]
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) ~[ejb-container.jar:na]
	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) ~[weld-osgi-bundle.jar:2013-06-27 10:15]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) ~[ejb-container.jar:na]
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140) ~[ejb-container.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655) ~[ejb-container.jar:na]
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212) ~[ejb-container.jar:na]
	... 72 common frames omitted

[Updated on: Thu, 01 August 2013 07:58]

Report message to a moderator

Re: JPA 2.1 @Converter bug? [message #1082438 is a reply to message #1077070] Thu, 08 August 2013 15:07 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please include the caused by exception.


James : Wiki : Book : Blog : Twitter
Previous Topic:Problem with table generation using a converter and column length
Next Topic:Cache Annotation
Goto Forum:
  


Current Time: Thu Oct 02 16:33:38 GMT 2014

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

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