Thanks for the response. What other information can I provide that would
help? I feel like I've tried everything that the jooq docs say and I've
provided everything I can think of.
The only reason I had my converter using Long is because the stacktrace
error said it was failing to convert Long. I tried changing my converter to
use Timestamp instead of Long:
public class ZonedDateTimeConverter implements Converter<Timestamp,
ZonedDateTime> {
@Override
public ZonedDateTime from(Timestamp timestamp) {
ZonedDateTime zonedDateTime =
ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.systemDefault());
return zonedDateTime;
}
@Override
public Timestamp to(ZonedDateTime zonedDateTime) {
return new Timestamp(zonedDateTime.toInstant().getEpochSecond() * 1000L);
}
@Override
public Class<Timestamp> fromType() {
return Timestamp.class;
}
@Override
public Class<ZonedDateTime> toType() {
return ZonedDateTime.class;
}
}
I've tried to make my <types> tag in my pom both timestamp and TIMESTAMP.
No matter what I do, my converter doesn't trigger. Is there something
specific I have to change in my query?
List<Foo> foos = create.select()
.from(FOO)
.limit(pageable.getPageSize())
.offset(pageable.getOffset())
.fetchInto(Foo.class);
I've attached a file, converter.png, showing the code it drops into before
failing with that error. As you can see, there is no condition for
ZonedDateTime, so of course it fails. I assume that if the converter is
working, it will intercept before the code even gets here and this won't be
a problem.
Thanks for your time.
On Friday, November 18, 2016 at 6:16:07 AM UTC-5, Lukas Eder wrote:
>
>
>
> 2016-11-18 11:52 GMT+01:00 Excrulon <[email protected] <javascript:>>:
>
>> Giving up for the night, but want to leave this here to make sure I'm
>> thinking about this whole thing correctly.
>>
>> I was under the impression that a converter is for when you come across a
>> certain type of column data type and you want to change it to a java object.
>>
> Yes.
>
>> Example... a table in my postgres db has columns of type timestamp. So I
>> would declare timestamp in the types tag.
>>
> Yes indeed.
>
>> This makes it so whenever I run a jooq query and one of the columns is of
>> type timestamp, it will automatically trigger the converter class I have
>> defined for that type and run the proper overridden method that tells how
>> to convert it to my target result, ZonedDateTime.
>>
> Exactly.
>
>> You're saying it should be bigint over timestamp though... so am I
>> completely wrong on all of this?
>>
> No, I was confused by your code, which is why I brought up BIGINT. But
> certainly, there's something wrong somewhere because your converter uses
> java.lang.Long, rather than java.sql.Timestamp as the binding for the <T>
> type variable.
>
> Perhaps we don't have all the information to help you just yet?
>
--
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.