2013/9/6 Lukas Eder <[email protected]> > Hello, > > 2013/9/6 Eric Schwarzenbach <[email protected]> > >> I'm trying to use JOOQ to dynamically create some statements once and >> store them, and then as needed attach them to a connection and bind >> parameters to them and execute them. In my initial development this seems >> to be working, and JOOQ has been a great help. At first I was unsure JOOQ >> was going to give me much value in this particular case, as the table and >> field names to be used were coming in dynamically and so I was not using >> the generated classes. (It may be a slightly odd use case, I'll spare you >> the details!) But then I ran into datatype issues in binding values and >> formatting result data and found that introspecting the generated classes >> to get datatypes solved my problems. >> >> Making this work so far has been all well and good, however, in >> refactoring my proof-of-concept code to really separate the storing and >> usage of Queries, it occurs to me that seems to be no way to detach queries >> when I am done with them. I'm not sure this is a pragmatic concern, perhaps >> it is just aesthetic. I kind of expect the semantics to be consistent and >> leaving a Query hanging around still attached between uses just seems wrong. >> > > Your concern is not "just aesthetic". In your use case, you should > probably detach queries again. This is illustrated in > DefaultDSLContext.fetch(ResultQuery): > > @Override > public <R extends Record> Result<R> fetch(ResultQuery<R> query) { > final Configuration previous = Utils.getConfiguration(query); > > try { > query.attach(configuration); > return query.fetch(); > } > finally { > query.attach(previous); > } > } >
I forgot to agree with adding Attachable.detach() https://github.com/jOOQ/jOOQ/issues/2726 Already now, you can detach attachables, by passing a null Configuration: query.attach(null); This is not very intuitive, though, so I'll add a detach() method. -- 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.
