Hi,
I think it could be much easier to ask for @Resource DataSource, and use
just that for jOOQ...
You can create a producer which provides DSLContext, so in any bean you can
just @Inject it instead of EntityManager, or you can have both injected if
needed (EM using @PersistenceContext of course).
9 paź 2014 21:57 "John Edo" <[email protected]> napisał(a):

> Thanks Lukas
>
> I found that the following technique works quite nicely under Hibernate
> 4.3.5:
>
>  @Stateless
> public class *JooqTest* {
>
>     @PersistenceContext
>     private EntityManager em;
>
>     public String get() {
>         em.unwrap(Session.class).doWork(new Work() {
>             @Override
>             public void execute(final Connection conn) throws SQLException
> {
>                 final DSLContext create = DSL.using(conn,
> SQLDialect.POSTGRES);
>                 …
>
>
>
>
> On Tue, Sep 16, 2014 at 2:02 AM, Lukas Eder <[email protected]> wrote:
>
>> Hello,
>>
>> Thank you very much for your enquiry. Indeed, we're working on producing
>> examples where jOOQ is used in Java EE contexts, rather than Spring
>> contexts.
>>
>> In essence, however, it does not matter, as jOOQ simply wraps a JDBC
>> Connection or a DataSource as input. This has also been mentioned once by
>> Adam Bien on his airhacks:
>>  https://twitter.com/JavaOOQ/status/468285734504628224
>>
>> If you pass a container managed DataSource (with an implicit container
>> managed transaction associated with it), jOOQ will not notice and
>> transparently execute SQL for you.
>>
>> Beware, however, that the Criteria API will be able to access JPA's
>> cached entities, whereas writing jOOQ queries corresponds to writing native
>> SQL via JPA.
>>
>> Hope this helps,
>> Lukas
>>
>> 2014-09-15 23:16 GMT+02:00 <[email protected]>:
>>
>>> I'm looking to replace our Criteria API queries with jOOQ.
>>>
>>> We're running a J2EE environment, under JBoss 8 with Hibernate as our
>>> JPA provider, and JBossTS as our full XA JTA provider.
>>>
>>> At the moment, our Criteria API queries are made from within Container
>>> Managed Transactions.
>>>
>>> Is it possible to simply replace these Criteria API queries with jOOQ
>>> queries using the existing Container Managed Transaction?
>>>
>>> I see there is an example for integrating jOOQ with Spring's transaction
>>> mechanism, but I haven't a clue on the relationship between Spring and
>>> JPA/JTA.
>>>
>>> Any pointers would be much appreciated.
>>>
>>> Thanks
>>>
>>> --
>>> 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 a topic in the
>> Google Groups "jOOQ User Group" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/jooq-user/xkK48Mrh5so/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.
>

-- 
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.

Reply via email to