我试图从 oracle 序列中选择 nextval,但我不断收到“未给出连接”的消息。
@PersistenceContext
private EntityManager em_;
JPAQuery query = new JPAQuery(em_);
Long nextVal = query.uniqueResult(SqlExpressions.nextval("USER_ID_SEQ");
我找到了this commit启用“from-less 查询”,但我看到的 IllegalArgumentException 源自 JPAQueryBase,它似乎没有在该提交中进行修改。
蒂莫有一个example :
long result = query.uniqueResult(SQLExpressions.nextval("SEQ_1") );
但这对我不起作用。
我正在使用 querydsl 3.3.3 和 Hibernate 4.2.7。
最佳答案
JPA native 查询支持 from-less 查询,对于 Querydsl,这将是
SQLTemplates templates = ...
JPASQLQuery query = new JPASQLQuery(em_, templates);
Long nextVal = query.uniqueResult(SQLExpressions.nextVal("USER_ID_SEQ");
关于querydsl - 选择序列结果为 "No Joins Given",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24765609/