Sequence at Oracle using QueryDSL

1,352 views
Skip to first unread message

SAURAV PAUL

unread,
Nov 6, 2013, 10:55:26 AM11/6/13
to quer...@googlegroups.com
Hi,

I am using spring-jdbc and QueryDSL how shall I get the value from SEQUENCE at Oracle.

SimpleExpression sequenceExpression = SQLExpressions.nextval(Integer.class, "SEQ_1");
I want to execute SELECT SEQ_1.nextval FROM DUAL using QueryDSL . How can I acheive that using queryDSL.

Timo Westkämper

unread,
Nov 6, 2013, 2:07:55 PM11/6/13
to quer...@googlegroups.com

long result = query.uniqueResult(SQLExpressions.nextval("SEQ_1") );

Eduardo Garcia-Castrillon Triquell

unread,
Feb 1, 2016, 6:29:17 AM2/1/16
to Querydsl
Hi,

Is this still valid with QueryDSL 4? Currently using v4.0.8 and cannot make this work:

JPAQuery<Long> query = new JPAQuery<>(em);
long res = query.select(SQLExpressions.nextval("MY_SEQUENCE")).fetchOne();

Returns:

java.lang.IllegalArgumentException: No sources given

	at com.querydsl.jpa.JPAQueryBase.serialize(JPAQueryBase.java:56)
	at com.querydsl.jpa.JPAQueryBase.serialize(JPAQueryBase.java:50)
	at com.querydsl.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:98)
	at com.querydsl.jpa.impl.AbstractJPAQuery.fetchOne(AbstractJPAQuery.java:252)

timowest

unread,
Feb 1, 2016, 12:09:18 PM2/1/16
to Querydsl
It's supported with Querydsl JPA, not SQL.

timowest

unread,
Feb 1, 2016, 12:09:41 PM2/1/16
to Querydsl
Sorry, I meant it's supported with SQL not JPA

Eduardo Garcia-Castrillon Triquell

unread,
Feb 2, 2016, 2:11:20 AM2/2/16
to Querydsl
Perfect. Thanks!
Reply all
Reply to author
Forward
0 new messages