This is not related to H2 itself - I have the same behaviour at MySQL 
instance. And yes it is Hibernate transaction manager because right now I'm 
migrating the app from Hibernate to jooq and I can't just throw it away. 
But I have the same errors 
with org.springframework.jdbc.datasource.DataSourceTransactionManager so it 
is not directly involved.

I'm not sure about Jason's comment - he has been tried to commit 
transaction one more time and got an error. So I'm not trying to commit 
twice the same transaction - I just have many threads with many 
transactions that try to do a query. Maybe you store a connection somewhere 
inside record and then ten processing thread complete processing and new 
cycle have to begin JOOQ rely on old config-connection values?

On Friday, December 13, 2013 12:10:04 AM UTC+4, Lukas Eder wrote:
>
> Hi Alex,
>
> Thanks for the detailed report. I don't think this is a bug in jOOQ, but 
> maybe it is a "documentation bug", i.e. a flaw with what is currently 
> documented here:
>
> http://www.jooq.org/doc/3.2/manual/getting-started/tutorials/jooq-with-spring/#comment-1158280997
>
> Notice also Jason's comments on that manual page.
>
> Other possible issues that I can see:
> - You're using H2's MVCC mode, which is still somewhat experimental, I 
> believe.
> - Is your using the Spring HibernateTransactionManager intentional?
>
> Cheers
> Lukas
>
>
> 2013/12/12 <[email protected] <javascript:>>
>
>> Guys,
>>
>> I'm trying to jooq in a project with many concurrent web requests and I 
>> found really strange behaviour for simple finder methods. There is my code 
>> and test for testng
>>
>>  @Override
>>
>>     public UserBlock findById(int userId, int friendId) {
>>         UserBlockRecord record = using(config).fetchOne(USER_BLOCK, 
>> byId(userId, friendId));
>>  
>>
>>         return ((record == null) ? null : record.into(UserBlock.class));
>>     }
>>
>>  
>>  
>>
>>     @Test(threadPoolSize = 10, invocationCount = 100)
>>     public void concurrencyForFinder() {
>>
>>         new TransactionTemplate(transactionManager).execute(new 
>> TransactionCallbackWithoutResult() {
>>             @Override
>>             protected void doInTransactionWithoutResult(TransactionStatus 
>> status) {
>>
>>                 final Random random = new Random();
>>  
>>
>>                 userBlockDao.findById(random.nextInt(100), 
>> random.nextInt(100));
>>             }
>>
>>         });
>>     }
>>
>>     And here is how it is crashing
>>     
>>     org.jooq.exception.DataAccessException: SQL [select 
>> `user_block`.`user_id`, `user_block`.`friend_id`, 
>> `user_block`.`created_time`, `user_block`.`is_block` from `user_block` where 
>> (`user_block`.`user_id` = 87 and `user_block`.`friend_id` = 5)]; Connection 
>> is broken: "session closed" [90067-173]
>>      at org.jooq.impl.Utils.translate(Utils.java:1158)
>>
>>      at 
>> org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:495)
>>      at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:325)
>>      at 
>> org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:344)
>>
>>      at 
>> org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:335)
>>      at org.jooq.impl.SelectImpl.fetchLazy(SelectImpl.java:1044)
>>      at 
>> org.jooq.impl.DefaultDSLContext.fetchLazy(DefaultDSLContext.java:1778)
>>
>>      at org.jooq.impl.DefaultDSLContext.fetchOne(DefaultDSLContext.java:1758)
>>      at ***********.UserBlockDaoImpl.findById(UserBlockDaoImpl.java:48)
>>
>> I'm using Spring to couple everything together so there is my xml
>>
>>     <bean id="pooledDataSource" 
>> class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
>>         <property name="driverClass" value="org.h2.Driver"/>
>>         <property name="url" 
>> value="jdbc:h2:mem:testdb;LOCK_TIMEOUT=30000;MVCC=true;DB_CLOSE_DELAY=-1;MODE=MySQL;INIT=RUNSCRIPT
>>  FROM 'classpath:database/init_schema.sql';"/>
>>     </bean>
>>
>>     <bean id="dataSource" 
>> class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
>>                         <property name="targetDataSource" 
>> ref="pooledDataSource" />
>>     </bean>
>>
>>     <bean id="transactionManager" 
>> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
>>         <property name="sessionFactory" ref="sessionFactory" />
>>     </bean>
>>
>>     <bean id="jooqConfig" class="org.jooq.impl.DefaultConfiguration">
>>         <constructor-arg index="0">
>>             <bean class="org.jooq.impl.DataSourceConnectionProvider">
>>                 <constructor-arg ref="dataSource" />
>>             </bean>
>>         </constructor-arg>
>>         <constructor-arg index="1"><null /></constructor-arg>
>>         <constructor-arg index="2"><null /></constructor-arg>
>>         <constructor-arg index="3"><null /></constructor-arg>
>>         <constructor-arg index="4"><null /></constructor-arg>
>>         <constructor-arg index="5"><value 
>> type="org.jooq.SQLDialect">MYSQL</value></constructor-arg>
>>         <constructor-arg index="6">
>>             <bean class="org.jooq.conf.Settings">
>>                 <property name="renderSchema" value="false" />
>>                 <property name="statementType" value="STATIC_STATEMENT" />
>>             </bean>
>>         </constructor-arg>
>>         <constructor-arg index="7"><null /></constructor-arg>
>>     </bean>
>>
>> Is it somethign wrong with my config or I faced with a bug?
>>
>> Thank you,
>> Alex.
>>
>>  -- 
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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