-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate 2 - help with session.createSQLQuery
PostPosted: Thu Dec 18, 2008 2:35 pm 
Beginner
Beginner

Joined: Tue Aug 08, 2006 11:53 am
Posts: 37
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.