First off, I'm fairly new to jOOQ - and I have to say that I'm really
impressed with what I'm finding. Great stuff!
I am using version 3.5.1 on Java 7.
I have several fields in a Postgres db that are timestamps. I use Joda in
the business code, so part of bringing jOOQ into this project was adding a
converter like in the docs:
public class JooqJodaDateTimeConvertor implements Converter<Timestamp,
DateTime> {
@Override
public DateTime from(Timestamp databaseObject) {
if (databaseObject == null) {
return null;
}
return new DateTime(databaseObject.getTime());
}
@Override
public Timestamp to(DateTime dt) {
if (dt == null) {
return null;
}
return new Timestamp(dt.getMillis());
}
@Override
public Class<Timestamp> fromType() {
return Timestamp.class;
}
@Override
public Class<DateTime> toType() {
return DateTime.class;
}
}
This appears to work perfectly for record objects - I can pull records from
the database and get the contents of those fields without any issue - types
are correct, etc.
The issue appears when I try to fetch into a generated pojo. The types on
the pojo appear fine. For example:
private org.joda.time.DateTime createdAt;
[...]
@javax.validation.constraints.NotNull
public org.joda.time.DateTime getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(org.joda.time.DateTime createdAt) {
this.createdAt = createdAt;
}
But when I execute the following (I'm getting the field name from the user,
in truth - which is why I'm putting in a String here, by the way):
create.fetchOne(t, t.field("id").equal(id)).into(Test.class)
I get the following exception:
org.jooq.exception.MappingException: An error ocurred when mapping record
to class com.fluidapps.model.bootstrap.tables.pojos.Instance
at
org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
[resteasy-jaxrs-3.0.8.Final.ja
r:]
at
org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
[resteasy-jaxrs-3.0.8.Final.jar:]
at
org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
[resteasy-jaxrs-3.0.8.Final.jar
:]
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
[resteasy-jaxrs-3.0.8.Final.jar:]
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
[resteasy-jaxrs-3.0.8.Final.jar:]
[more jboss references removed . . . ]
Caused by: javax.ejb.EJBException: org.jooq.exception.MappingException: An
error ocurred when mapping record to class
com.fluidapps.model.bootstrap.tables.pojos.Instance
at
org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190)
[wildfly-ejb3-8.1.0.Final.jar:8.1.0.
Final]
at
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
[wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
at
org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:369)
[wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
at
org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:241)
[wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
[more jboss references removed . . . ]
Caused by: org.jooq.exception.MappingException: An error ocurred when
mapping record to class com.fluidapps.model.bootstrap.tables.pojos.Instance
at
org.jooq.impl.DefaultRecordMapper$MutablePOJOMapper.map(DefaultRecordMapper.java:493)
[jooq-3.5.1.jar:]
at
org.jooq.impl.DefaultRecordMapper.map(DefaultRecordMapper.java:331)
[jooq-3.5.1.jar:]
at org.jooq.impl.AbstractRecord.into(AbstractRecord.java:669)
[jooq-3.5.1.jar:]
at
com.fluidapps.enterprise.services.EntityService.findAndFillJooqEntity(EntityService.java:1133)
[FluidAppsManager-model.jar:]
at
com.fluidapps.enterprise.services.EntityService.findAndFillJooqEntity(EntityService.java:1089)
[FluidAppsManager-model.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rt.jar:1.7.0_10]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[rt.jar:1.7.0_10]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.7.0_10]
at java.lang.reflect.Method.invoke(Method.java:601)
[rt.jar:1.7.0_10]
at
org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at
org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
[more jboss references removed . . . ]
Caused by: org.jooq.exception.DataTypeException: Cannot convert from
2013-09-20T16:50:47.820Z (class org.joda.time.DateTime) to class
java.util.Date
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:873)
[jooq-3.5.1.jar:]
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:811)
[jooq-3.5.1.jar:]
at org.jooq.tools.Convert.convert0(Convert.java:300)
[jooq-3.5.1.jar:]
at org.jooq.tools.Convert.convert(Convert.java:292)
[jooq-3.5.1.jar:]
at org.jooq.tools.Convert.convert(Convert.java:360)
[jooq-3.5.1.jar:]
at org.jooq.impl.AbstractRecord.getValue(AbstractRecord.java:253)
[jooq-3.5.1.jar:]
at
org.jooq.impl.DefaultRecordMapper$MutablePOJOMapper.map(DefaultRecordMapper.java:486)
[jooq-3.5.1.jar:]
... 114 more
All the caused-bys are due to layers it bubbles up through, of course - I
would expect that the important parts should be the last 2.
I have searched the jOOQ site, Googled for anything that might solve this,
searched StackOverflow and this user group to no avail.
I have probably just missed something in my setup of the generator or
something. Please, can anybody help me work through this?
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.