Hi,
I got a quite curious problem. I wrote a DAOTest to check if my DAO implementation works fine.
Code:
When I run my DAOTest it works. Adding one line results in a crash, which origin is not understandable for me.Code:/** * 23.05.2005 * 11:52:05 * johannes.hiemer * SystemTypeDAOTest.java */ package itecon.dao.hibernate.test; import itecon.bo.dao.ISystemtypeDAO; import itecon.bo.model.Systemtype; import junit.awtui.TestRunner; import org.apache.log4j.Logger; /** * @author johannes.hiemer * * ITecon Dell Call System */ public class SystemTypeDAOTest extends BaseDAOTestCase { private Systemtype stype; private ISystemtypeDAO stypeDAO; protected void setUp() throws Exception { log = Logger.getLogger(SystemErrorDAOTest.class.getName()); stypeDAO = (ISystemtypeDAO) ctx.getBean("systemTypeDAO"); } protected void tearDown() throws Exception { stypeDAO = null; } public static void main(String args []) { TestRunner.run(SystemTypeDAOTest.class); } public Systemtype createSystemType() { stype = new Systemtype(); stype.setStprice("40,0€"); stype.setSttype("Server"); return stype; } public void testAddAndRemoveSystemType() { createSystemType(); log.info(stype); stypeDAO.saveSystemtype(stype); assertTrue("primary key assigned", stype.getStid() != null); log.info(stype); assertTrue(stype.getSttype() != null); stypeDAO.getSystemtype(stype.getStid()); assertTrue("primary key not assigned", stype.getStid() != null); } }
When I add this line behind:Code:log.info(stypeDAO.getSystemtypes());
stypeDAO.saveSystemtype(stype);
I a get an exception: systemtype is not mapped.
Stacktrace:
But what I am wondering is, that the insert in the line before (stypeDAO.saveSystemtype(stype);) works, but the complete select from the database doesn't. I checked if the Database got the inserted values. What's wrong with my implementation/DAOTest?Code:org.springframework.orm.hibernate3.HibernateQueryException: systemtype is not mapped. [from systemtype]; nested exception is org.hibernate.hql.ast.QuerySyntaxError: systemtype is not mapped. [from systemtype] org.hibernate.hql.ast.QuerySyntaxError: systemtype is not mapped. [from systemtype] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:196) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:425) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:880) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:830) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:749) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:740) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:732) at itecon.bo.dao.hibernate.SystemtypeDAOHibernate.getSystemtypes(SystemtypeDAOHibernate.java:42) at itecon.dao.hibernate.test.SystemTypeDAOTest.testAddAndRemoveSystemType(SystemTypeDAOTest.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: systemtype is not mapped. at org.hibernate.hql.ast.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:85) at org.hibernate.hql.ast.FromElementFactory.addFromElement(FromElementFactory.java:77) at org.hibernate.hql.ast.FromClause.addFromElement(FromClause.java:67) at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:217) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2830) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) ... 27 more
I hope you can help me.
Thanks a lot
Johannes


Reply With Quote