Hi- my use case is to select the oracle sequence dynamically (based on the user data) and then get the next value. I tried using the below posted code but i get a exception. Appreciate some help on this
thank you in advance
Hibernate version: 2.1.8
Code between sessionFactory.openSession() and session.close():
Code:
session.createSQLQuery("SELECT " + sequenceName + ".NEXTVAL as id from dual", "id", Number.class).uniqueResult();
Full stack trace of any exception that occurs:
org.springframework.orm.hibernate.HibernateSystemException: Unknown entity class: java.lang.Number; nested exception is net.sf.hibernate.MappingException: Unknown entity class: java.lang.Number
Caused by: net.sf.hibernate.MappingException: Unknown entity class: java.lang.Number
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2718)
at net.sf.hibernate.impl.SessionImpl.getSQLLoadable(SessionImpl.java:3878)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3857)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:550)
at com.equifax.ic.tdp.framework.catalog.dao.HibernateShortIdGeneratorDao$1.doInHibernate(HibernateShortIdGeneratorDao.java:42)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:369)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:336)
at com.equifax.ic.tdp.framework.catalog.dao.HibernateShortIdGeneratorDao.getShortId(HibernateShortIdGeneratorDao.java:34)
at com.equifax.ic.tdp.framework.catalog.dao.HibernateShortIdGeneratorDaoTest.testGetShortId(HibernateShortIdGeneratorDaoTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Name and version of the database you are using:Oracle 10g