Hello,

2013/8/19 Christian Hammers <[email protected]>

> Hello
>
> In my application I would like to use POJOs to transfer data via SOAP or
> modify values with JSF and already figured out how to generate them with
> JOOQ.
> As the optionally generated DAO classes do not offer very much functions I
> guessed that I can live without and use the ActiveRecord classes to
> retrieve and store POJOs like this:
>
>   // Load via ActiveRecord and store into POJO
>   Author a = jooq.selectFrom(AUTHOR).fetchOne().into(Author.class);
>   ...
>   // Later, load current values from DB, update from POJO and store changes
>   AuthorRecord ar2 =
> jooq.selectFrom(AUTHOR).where(AUTHOR.ID.eq(a.getId())).fetchOne();
>   ar2.from(a);
>   jooq.executeUpdate(ar2);
>
> The Record.from() method will set the "changed" flags for all attributes
> to true, though,
> which makes ugly long UPDATE statement..
> (Some reason were given in the recent thread about "Dirty checks
> return...")
>
> My questions are now:
> 1. Does my approach makes sense or am I unnecessarily strict with my
> layers and using ActiveRecord objects in JSF managed beans or webservices
> is standard practice?
>

There is a Setting that you can use to fetch "unattached" records through
jOOQ, if you want to use ActiveRecords outside of the data layer:
http://www.jooq.org/javadoc/latest/org/jooq/conf/Settings.html#attachRecords

This will create records with no Configuration attached to them. In other
words, prior to calling store() or update(), you will need to "re-attach"
them through
http://www.jooq.org/javadoc/latest/org/jooq/Attachable.html#attach(org.jooq.Configuration)


> 2..Would make sense to add a flag to Record.from() that, if set, only
> alters the "changed" flags of fields whose values differ from their
> originals?
>

I'm not sure if the manipulation of these "changed" flags should be
first-class API citizens in methods other than the Record.changed()
methods. I can see though, that the current implementation of "changed"
alteration doesn't suit everyone. I'll think about this:
https://github.com/jOOQ/jOOQ/issues/2704

Concerning overrides of the implementation of Record.from(), there is a
more thorough feature request on the roadmap about adding a RecordUnmapper
type:
https://github.com/jOOQ/jOOQ/issues/2520

This type (and a corresponding RecordUnmapperProvider SPI) could be used to
override Record.from() behaviour in general.

Cheers
Lukas

-- 
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/groups/opt_out.

Reply via email to