Hi Bjoern, Thanks a lot for your message.
First off, a remark that isn't related to your bug about this line: .constraints(DSL.constraint(TableName.toString() + "_" + ObjectID.toString()).primaryKey(ObjectID)) I'd be careful when using jOOQ's QueryPart.toString() methods. By default, they render with all names being quoted. Perhaps, a better method to choose here is Table.getName() and Field.getName(). Can you please post the stack trace of your ClassCastEception? Thanks, Lukas 2017-07-08 14:42 GMT+02:00 <[email protected]>: > Forgot to add the code snipped used to read from the database. > > Result<Record> r = dc.selectFrom(CEntityCarPostingLink. > TableName).limit(100).fetch(); > final LinkedList<CEntityCarPostingLink> result = new > LinkedList<>(); > for (Record a : r) { result.add(new CEntityCarPostingLink(a. > getValue(CEntityCarPostingLink.ObjectID))); } > > > > > > I think this is a bug. > >> >> Have following table definition: >> >> public final static Table TableName = DSL.table(DSL.name(CEntityCarP >> ostingLink.class.getSimpleName())); >> public final static Field<CUUID> ObjectID = DSL.field(DSL.name( >> "ObjectID"), SQLDataType.BLOB.nullable(false).asConvertedDataType(new >> CUUIDConverter())); private final CUUID m_ObjectID; >> JooqContext.createTableIfNotExists(TableName) >> .column(ObjectID) >> .constraints(DSL.constraint(TableName.toString() + "_" + >> ObjectID.toString()).primaryKey(ObjectID)) >> .execute(); >> >> >> The code for the converter is: >> >> public final class CUUIDConverter implements Converter<byte[], CUUID> { >> @Override public CUUID from(byte[] T) { return T == null ? null : new >> CUUID(T); } >> @Override public byte[] to(CUUID U) { return U == null ? null : U. >> bytes(); } >> @Override public Class<byte[]> fromType() { return byte[].class; } >> @Override public Class<CUUID> toType() { return CUUID.class; } >> } >> >> >> When writing to the database, i.e. doing insert or update, I feed an >> instance of CUUID and Jooq converts it to a byte-array and writes to >> database. >> >> Yet, when reading from database, I get a ClassCastException. >> >> In the debugger I think I pinpointed to >> >> ... >> 42 package org.jooq.impl; >> ... >> 113 @SuppressWarnings({ "rawtypes", "unchecked" }) >> 114 abstract class AbstractRecord extends AbstractStore implements Record >> { >> ... >> 222 >> 223 @Override >> 224 public final <T> T get(Field<T> field) { >> 225 return (T) get(indexOrFail(fieldsRow(), field)); >> 226 } >> 227 >> ... >> >> Shouldn't the get-Method invoke the Converter / Binding assigned to the >> field, instead of doing simply a cast to T? >> >> >> Best >> Bjoern >> > -- > 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. > -- 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.
