0

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?

1 Answer 1

1

You need to use the createNativeQuery method to execute SQL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.