Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in Hibernate Mapping Entity class with DB table using Annotations

ashwin bala
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am building a sample spring hibernate application.Spring part is working fine.In hibernate I have mapped the bean class and the table.Still I get a error saying bean class is not mapped.Please find the attached code for reference.need your help fixing this.


Following is the stack trace

Aug 08, 2016 4:53:10 PM prepareRefresh
INFO: Refreshing startup date [Mon Aug 08 16:53:10 IST 2016]; root of context hierarchy
Aug 08, 2016 4:53:10 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [Spring.xml]
Aug 08, 2016 4:53:11 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver:
Aug 08, 2016 4:53:12 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.3.Final}
Aug 08, 2016 4:53:12 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.11.Final}
Aug 08, 2016 4:53:12 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: not found
Aug 08, 2016 4:53:12 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 08, 2016 4:53:12 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.SQLServer2008Dialect
Aug 08, 2016 4:53:12 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Aug 08, 2016 4:53:12 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
**Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: Circle is not mapped [from Circle]
    at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(
    at org.hibernate.QueryException.wrapWithQueryString(
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(
    at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(
    at org.hibernate.internal.AbstractSessionImpl.createQuery(
    at org.hibernate.internal.SessionImpl.createQuery(
    at re.test.HibernateDAOImpl.getTableCount(
    at re.test.JDBCDemo.main(
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Circle is not mapped
    at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(
    at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(
    at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(
    at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(
    ... 9 more**
Roel De Nijs
Posts: 10763
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have your entity class Circle mapped as a spring-managed bean. That makes no sense at all!

You should have either a META-INF/persistence.xml to define your persistence unit or set the packagesToScan property of the LocalContainerEntityManagerFactoryBean to the appropriate package (containing all your entityies). See this tutorial for more information
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!