i am trying to access the below sql to generate the next sequence number. i am getting QuerySyntaxException caused by dual is not mapped.
sql = Select sequence_caseid.NEXTVAL from DUAL
public Long generate(Session session)
throws DataRetrievalFailureException, SQLDataException {
Long result = null;
Query<?> query = (Query) session.createQuery(sql);
result = new Long(query.getFirstResult());
return result;
}
bean definition for generators
<bean id="generatorVoucherId" class="com.sample.OracleSequenceGenerator">
<constructor-arg type="java.lang.String"><value>${logger.name}</value></constructor-arg>
<property name="generatorName"><value>sequence_caseid</value></property>
</bean>
i dont have an hbm.xml for this dual. Do i need one? if so how to create one? i have multiple sequence generators in oracle like this, can i make one for all of it?
You need to use the
createNativeQuery
method to execute SQL.