Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate select from a table

 
Kamil Rak
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem with hibernate.
I hava a table "rezerwacja" which has been created via annotations. When I try to get the data from it, I get the Exception "rezerwacja is not mapped" (Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: rezerwacja is not mapped [from rezerwacja]).

Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: rezerwacja is not mapped [from rezerwacja]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:111)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:327)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3441)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3325)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:733)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:584)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:256)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
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:124)
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:1770)
at com.kamil.aktywujRezerwacje.PokazRezerwacje.main(PokazRezerwacje.java:17)



Could you help me to fix it?

Here are the classes



----------------------



Hibernate.cfg.xml



Insert into table works fine - I have created a xhtml file and the records are in the DB, but - as I said - when I try to get the data it won't work.

Here is the class:



As you can see there is a <mapping resource="hibernate.hbm.xml" /> in the hibernate configuration file. When I remove the comment lines I get also an Exception
Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: com.kamil.rezerwacja.Rezerwacja column: nrtelefonu (should be mapped with insert="false" update="false")

Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: com.kamil.rezerwacja.Rezerwacja column: nrtelefonu (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:676)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:698)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:720)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:474)
at org.hibernate.mapping.RootClass.validate(RootClass.java:235)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1362)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1865)
at com.kamil.rezerwacja.HibernateUtil.getSessionFactory(HibernateUtil.java:12)
at com.kamil.aktywujRezerwacje.PokazRezerwacje.main(PokazRezerwacje.java:16)


The hibernate.hbm.xml is:


 
Kamil Rak
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was, it should be "from Rezerwacja", not "from rezerwacja" which is imho stragne because the table name is rezerwacja...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic