Hi Rick

2016-11-17 18:07 GMT+01:00 <rick.latr...@gmail.com>:

> Thanks, I understand the issue.
>
> But keep in mind, that the main issue in serialization and deserialization
> of jOOQ Records is the aforementioned use of toString as a last resort.
> toString will yield in almost any case to serialized (json) data which is
> not deserializable anymore, as user types usually don't have a string based
> constructor.
>

You're right. I'm sorry, I've overlooked that detail. I do think that is a
separate topic from the binding/converter issue. I mean, if you want the
BIGINT to be serialised to JSON, then why put a converter there in the
first place? The converter will guarantee that the Result<?> object will
contain your user type, not the database type. From then on, the database
type is irrelevant in all further processing.

Now, I do agree that there should be extra functionality to intercept that
last resort toString() call.


> So I would suggest to go with sql datatypes <T>.
> Here the value of the user type <U> needs to be converted back to <T>
> during format json.
> Then serialize the known sql datatype to json.
> In this case json would have BIGINT with the Long value.
>

Again, I don't see the point of your suggestion:

1. From a backwards compatibility perspective, that change is almost
impossible (imagine a converter that doesn't change the type but just the
value, etc...)
2. Why have a converter in place in the first place, if you as a user
*know* that you'll want the database type in the end result?

In any case, I think that you're right in general, and jOOQ should offer an
SPI (probably based again on Converter) for custom serialisation /
deserialisation, e.g. a Converter<T, String>. I've registered another
feature request for this:
https://github.com/jOOQ/jOOQ/issues/5673

Does that respond to your needs?

-- 
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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to