0

I just set up a basic hibernate/spring project to test some stuff. I use a MySQL db by using WAMP.

These are all of the classes: http://codepaste.net/7pwmtx

This is my bean definition and pom file: http://codepaste.net/4iz7jb

POM is a little bit messy but this is the problem: I think that I set up my dialect properly because I get no errors when i add something to the db. I get errors when I use find in hql. I t seems like hibernate isnt retrieving data from the same place that it is putting it. Any idea why this doesnt work?

By the way, the console output was:

Exception in thread "main" org.springframework.orm.hibernate3.HibernateQueryException: hobject is not mapped [from hobject]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: hobject is not mapped [from hobject]
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:660)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
    at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
    at hibernate.dao.SpringHibernateOperatorImplementation.getAllRows(SpringHibernateOperatorImplementation.java:24)
    at hibernate.main.HibernateMain.main(HibernateMain.java:22)
Caused by: org.hibernate.hql.ast.QuerySyntaxException: hobject is not mapped [from hobject]
    at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
    at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
    at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
    at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
    at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
    at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:914)
    at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
    ... 5 more
James Gregory
  • 14,173
  • 2
  • 42
  • 60
why_vincent
  • 2,172
  • 9
  • 33
  • 49
  • This error means you haven't inform which classes should hibernate manage, or at least there is no class named hobject managed by hibernate, please paste your configuration here – Francisco Spaeth Oct 24 '11 at 11:04
  • It is supposed to be configured by the annotation so I don't use a configuration file. Look in the .xml file and you'll see that I use annotations for that and that I set the properties in the beandefinitionfile. – why_vincent Oct 24 '11 at 11:06
  • but why are you using String hql = "from hobject" instead of "from HObject"? – Francisco Spaeth Oct 24 '11 at 11:34
  • Tried HOBJECT HObject and hobject, same result for all three.... – why_vincent Oct 24 '11 at 12:06

1 Answers1

1

Add the entity class hibernate.dao.HObject to hibernate.cfg.xml files. It is neeeded even if you are using annotation based configurations.

If you want to skip adding these to cfg file you can use the approach mentioned here provided you are using spring.

Community
  • 1
  • 1
ManuPK
  • 11,623
  • 10
  • 57
  • 76