我编写Spring + Vaadin应用程序。我想添加QueryDSL来访问数据库(Oracle)。我查看了文档(http://docs.spring.io/spring-data/jdbc/docs/current/reference/html/core.querydsl.html),并阅读了Spring建议使用标准QueryDSL api的内容。我依赖于以下方面来介绍我的项目:
com.mysema.querydsl querydsl-sql-spring ${querydsl.version} org.springframework spring-jdbc ${spring.version} org.apache.commons commons-dbcp2 2.1.1 com.mysema.querydsl querydsl-sql ${querydsl.version}
我的beans.xml如下:
在我的DatabaseFacade
实现中,执行以下配置:
private SQLQueryFactory query; @Autowired @Qualifier("DataSource") public void setDataSource(DataSource dataSource) { Providerprovider = new SpringConnectionProvider(dataSource); Configuration configuration = new Configuration(new OracleTemplates()); configuration.setExceptionTranslator(new SpringExceptionTranslator()); query = new SQLQueryFactory(configuration, provider); }
不幸的是,每次我开始申请时,我都会得到:
10:29:54.490 [main] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource 10:29:56.231 [main] ERROR c.r.i.k.b.impl.DatabaseFacadeImpl - Error happend in com.roche.icc.kps.backend.impl.DatabaseFacadeImpl.getEditableKPSStores 10:29:56.234 [main] ERROR c.r.i.k.b.impl.DatabaseFacadeImpl - Connection is not transactional java.lang.IllegalStateException: Connection is not transactional at com.mysema.query.sql.spring.SpringConnectionProvider.get(SpringConnectionProvider.java:45) ~[querydsl-sql-spring-3.7.0.jar:na] at com.mysema.query.sql.spring.SpringConnectionProvider.get(SpringConnectionProvider.java:33) ~[querydsl-sql-spring-3.7.0.jar:na] at com.mysema.query.sql.SQLQueryFactory.query(SQLQueryFactory.java:63) ~[querydsl-sql-3.7.0.jar:na] at com.mysema.query.sql.SQLQueryFactory.query(SQLQueryFactory.java:28) ~[querydsl-sql-3.7.0.jar:na] at com.mysema.query.sql.AbstractSQLQueryFactory.from(AbstractSQLQueryFactory.java:54) ~[querydsl-sql-3.7.0.jar:na]
有没有人遇到这个问题?我应该使用其他DataSource
(Atomikos吗?)?
感谢帮助!
卡米尔