【发布时间】:2017-08-19 00:17:18
【问题描述】:
我有一个和这个非常相似的代码:
dslContext.transaction(new TransactionalRunnable()
{
@Override
public void run(Configuration arg0) throws Exception
{
dao1.insert(object1);
//Object 1 is inserted in the database
//despite the exception that is being thrown
if(true)
throw new RuntimeException();
dao2.insert(object2)
}
});
这是我用来创建 dsl 上下文和使用 JOOQ 生成的 daos 的代码。
ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
comboPooledDataSource.setDriverClass(org.postgresql.Driver.class.getName());
comboPooledDataSource.setJdbcUrl("jdbc:postgresql://localhost:5432/database?searchpath=schema");
comboPooledDataSource.setUser("user");
comboPooledDataSource.setPassword("password");
comboPooledDataSource.setMinPoolSize(5);
comboPooledDataSource.setAcquireIncrement(5);
comboPooledDataSource.setMaxPoolSize(25);
Configuration configuration=new DefaultConfiguration().set(comboPooledDataSource).set(
SQLDialect.POSTGRES);
DSLContext dslContext=DSL.using(configuration);
Dao1 dao1=new Dao1(configuration);
Dao2 dao2=new Dao2(configuration);
为什么我会出现这种行为?
【问题讨论】:
-
I have a code that is very similar to this one:,当您运行发布的代码时,您的行为是否相同? -
您使用的是什么 jOOQ 版本?您能说明一下您的
comboPooledDataSource是如何配置的吗? -
@LukasEder 我正在使用 3.9.1 版的 JOOQ,我已经更新了问题。