Hello On Tue, 20 Aug 2013 09:30:25 +0200 Lukas Eder <[email protected]> wrote:
> 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) So essentially I would castrate my ActiveRecord objects to POJOs as every call to .store()/.update() without a configuration leads to a DetachedException(). Retrieving an unattached ActiveRecord object and then attaching it prior to .store() works fine. As I have a @SessionScoped Bean, though, I would then have to un-attach the configuration after the .store() again, right? How can I do that? There seems no method for that. bye, -christian- -- 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.
