-->
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.  [ 5 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: Unknown entity:
PostPosted: Wed Oct 12, 2005 6:33 pm 
Newbie

Joined: Wed Oct 12, 2005 6:27 pm
Posts: 3
Can you help me in fixing this?



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.tiaa.advice.naviplan.sor.data">
<sql-query name="ClientPlanList">
<return alias="cp" class="org.tiaa.advice.naviplan.sor.data.ClientPlanVO"/>
select distinct a2.plan_id as {cp.planId}, a1.client_id as {cp.clientId} from clnt_engmnt a1, clnt_engmnt_plan a2, plan_version a3 where a1.engagement_id = a2.engagement_id and a2.plan_id = a3.plan_id and a3.status=30
</sql-query>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
session = HibernateUtils.sessionFactory.openSession(conn);
List cpList = session.getNamedQuery("ClientPlanList").list();
System.out.println("The list is "+cpList);
//List cpList = session.
session.close();

Full stack trace of any exception that occurs:
org.hibernate.MappingException: Unknown entity: org.tiaa.advice.naviplan.sor.data.ClientPlanVO
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.getSQLLoadable(SQLQueryReturnProcessor.java:53)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processRootReturn(SQLQueryReturnProcessor.java:119)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:98)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:87)
at org.hibernate.loader.custom.SQLCustomQuery.<init>(SQLCustomQuery.java:105)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:144)
at org.tiaa.advice.naviplan.sor.dao.ClientPlanListDAO.getClientPlanList(ClientPlanListDAO.java:27)
at org.tiaa.advice.naviplan.sor.core.SORController.execute(SORController.java:30)
at org.tiaa.advice.naviplan.sor.core.SORMain.main(SORMain.java:20)
Exception in thread "main"

Name and version of the database you are using:
Oracle9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

18:18:54,588 INFO Environment:464 - Hibernate 3.0.5
18:18:54,588 INFO Environment:477 - hibernate.properties not found
18:18:54,604 INFO Environment:510 - using CGLIB reflection optimizer
18:18:54,604 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
18:18:54,698 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
18:18:54,698 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
18:18:54,776 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
18:18:54,776 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
18:18:54,854 DEBUG Configuration:1067 - connection.pool_size=1
18:18:54,854 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.OracleDialect
18:18:54,854 DEBUG Configuration:1067 - hibernate.show_sql=true
18:18:54,854 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@513cf0 [Attribute: name resource value "SORQueries.hbm.xml"]
18:18:54,854 INFO Configuration:444 - Mapping resource: SORQueries.hbm.xml
18:18:54,870 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
18:18:54,870 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
18:18:54,995 DEBUG HbmBinder:2432 - Named SQL query: ClientPlanList -> select distinct a2.plan_id as {cp.planId}, a1.client_id as {cp.clientId} from clnt_engmnt a1, clnt_engmnt_plan a2, plan_version a3 where a1.engagement_id = a2.engagement_id and a2.plan_id = a3.plan_id and a3.status=30
18:18:55,010 INFO Configuration:1222 - Configured SessionFactory: null
18:18:55,010 DEBUG Configuration:1223 - properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\j2sdk1.4.1_02\jre\bin, java.vm.version=1.4.1_02-b06, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\eclipse\workspace\SOR, java.runtime.version=1.4.1_02-b06, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\j2sdk1.4.1_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\kumarse\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2000, sun.java2d.fontpath=, java.library.path=C:\j2sdk1.4.1_02\bin;.;C:\WINNT\System32;C:\WINNT;C:\WebObjects\Developer\Executables\Utilities;C:\WebObjects\Developer\Executables;C:\WebObjects\Local\Library\Executables;C:\WebObjects\Library\JDK\bin;C:\WebObjects\Library\Executables;C:\Oracle8I\ora81\bin;C:\Program Files\Oracle\jre\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~1\CA\Common\SCANEN~1;C:\PROGRA~1\CA\eTrust\INOCUL~1;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;C:\Program Files\Starbase\StarGate SDK\Lib;C:\Program Files\Hummingbird\Connectivity\8.00\Accessories\;C:\cygwin\bin;C:\cygwin\usr\bin;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility;c:\TiaaApps\St01\TiaaShared\Executables;q:/EntireX/621;C:\MSSQL\BINN;C:\MSSQL7\BINN;C:\j2sdk1.4.1_02\bin;C:\Program Files\TPWEBPRO;C:\PROGRA~1\TPWEBPRO;Z:.;Y:.;, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=1, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.0, user.home=C:\Documents and Settings\kumarse, user.timezone=America/New_York, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, user.name=KUMARSE, java.class.path=C:\eclipse\workspace\SOR\implementation\src\java;C:\eclipse\workspace\SOR\implementation\config;C:\eclipse\workspace\SOR\implementation\mapping;C:\eclipse\workspace\SOR\implementation\lib\ant-antlr-1.6.3.jar;C:\eclipse\workspace\SOR\implementation\lib\asm.jar;C:\eclipse\workspace\SOR\implementation\lib\asm-attrs.jar;C:\eclipse\workspace\SOR\implementation\lib\cglib-2.1.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-collections-2.1.1.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-logging-1.0.4.jar;C:\eclipse\workspace\SOR\implementation\lib\dom4j-1.6.jar;C:\eclipse\workspace\SOR\implementation\lib\ehcache-1.1.jar;C:\eclipse\workspace\SOR\implementation\lib\hibernate3.jar;C:\eclipse\workspace\SOR\implementation\lib\jta.jar;C:\eclipse\workspace\SOR\implementation\lib\log4j-1.2.9.jar;C:\eclipse\workspace\SOR\implementation\lib\classes12.jar;C:\eclipse\workspace\SOR\implementation\lib\AppParametersUtility.jar;C:\eclipse\workspace\SOR\implementation\lib\sor_request.jar;C:\eclipse\workspace\SOR\implementation\lib\sor_response.jar;C:\eclipse\workspace\SOR\implementation\lib\jakarta-regexp-1.2.jar;C:\eclipse\workspace\SOR\implementation\lib\tiaa-logging.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-lang.jar;C:\tiaaconfigs\appparams;C:\tiaaconfigs\log4j, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\j2sdk1.4.1_02\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.OracleDialect, connection.pool_size=1, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.1_02, java.ext.dirs=C:\j2sdk1.4.1_02\jre\lib\ext, sun.boot.class.path=C:\j2sdk1.4.1_02\jre\lib\rt.jar;C:\j2sdk1.4.1_02\jre\lib\i18n.jar;C:\j2sdk1.4.1_02\jre\lib\sunrsasign.jar;C:\j2sdk1.4.1_02\jre\lib\jsse.jar;C:\j2sdk1.4.1_02\jre\lib\jce.jar;C:\j2sdk1.4.1_02\jre\lib\charsets.jar;C:\j2sdk1.4.1_02\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=org.hibernate.dialect.OracleDialect, sun.cpu.isalist=pentium i486 i386}
18:18:55,026 DEBUG Configuration:998 - Preparing to build session factory with filters : {}
18:18:55,026 INFO Configuration:875 - processing extends queue
18:18:55,026 INFO Configuration:879 - processing collection mappings
18:18:55,026 INFO Configuration:888 - processing association property references
18:18:55,026 INFO Configuration:917 - processing foreign key constraints
18:18:55,026 WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
18:18:55,073 INFO Dialect:92 - Using dialect: org.hibernate.dialect.OracleDialect
18:18:55,166 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
18:18:55,166 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
18:18:55,166 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
18:18:55,166 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
18:18:55,182 INFO SettingsFactory:144 - Scrollable result sets: disabled
18:18:55,182 DEBUG SettingsFactory:148 - Wrap result sets: disabled
18:18:55,182 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
18:18:55,182 INFO SettingsFactory:160 - Connection release mode: null
18:18:55,182 INFO SettingsFactory:187 - Default batch fetch size: 1
18:18:55,182 INFO SettingsFactory:191 - Generate SQL with comments: disabled
18:18:55,182 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
18:18:55,182 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
18:18:55,182 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
18:18:55,182 INFO SettingsFactory:203 - Query language substitutions: {}
18:18:55,198 INFO SettingsFactory:209 - Second-level cache: enabled
18:18:55,198 INFO SettingsFactory:213 - Query cache: disabled
18:18:55,198 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
18:18:55,198 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
18:18:55,198 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
18:18:55,198 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
18:18:55,213 INFO SettingsFactory:257 - Echoing all SQL to stdout
18:18:55,213 INFO SettingsFactory:261 - Statistics: disabled
18:18:55,213 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
18:18:55,213 INFO SettingsFactory:279 - Default entity-mode: pojo
18:18:55,385 INFO SessionFactoryImpl:152 - building session factory
18:18:55,385 DEBUG SessionFactoryImpl:161 - Session factory constructed with filter configurations : {}
18:18:55,385 DEBUG SessionFactoryImpl:164 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\j2sdk1.4.1_02\jre\bin, java.vm.version=1.4.1_02-b06, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\eclipse\workspace\SOR, java.runtime.version=1.4.1_02-b06, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\j2sdk1.4.1_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\kumarse\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2000, sun.java2d.fontpath=, java.library.path=C:\j2sdk1.4.1_02\bin;.;C:\WINNT\System32;C:\WINNT;C:\WebObjects\Developer\Executables\Utilities;C:\WebObjects\Developer\Executables;C:\WebObjects\Local\Library\Executables;C:\WebObjects\Library\JDK\bin;C:\WebObjects\Library\Executables;C:\Oracle8I\ora81\bin;C:\Program Files\Oracle\jre\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~1\CA\Common\SCANEN~1;C:\PROGRA~1\CA\eTrust\INOCUL~1;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;C:\Program Files\Starbase\StarGate SDK\Lib;C:\Program Files\Hummingbird\Connectivity\8.00\Accessories\;C:\cygwin\bin;C:\cygwin\usr\bin;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility;c:\TiaaApps\St01\TiaaShared\Executables;q:/EntireX/621;C:\MSSQL\BINN;C:\MSSQL7\BINN;C:\j2sdk1.4.1_02\bin;C:\Program Files\TPWEBPRO;C:\PROGRA~1\TPWEBPRO;Z:.;Y:.;, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=1, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.0, user.home=C:\Documents and Settings\kumarse, user.timezone=America/New_York, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, user.name=KUMARSE, java.class.path=C:\eclipse\workspace\SOR\implementation\src\java;C:\eclipse\workspace\SOR\implementation\config;C:\eclipse\workspace\SOR\implementation\mapping;C:\eclipse\workspace\SOR\implementation\lib\ant-antlr-1.6.3.jar;C:\eclipse\workspace\SOR\implementation\lib\asm.jar;C:\eclipse\workspace\SOR\implementation\lib\asm-attrs.jar;C:\eclipse\workspace\SOR\implementation\lib\cglib-2.1.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-collections-2.1.1.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-logging-1.0.4.jar;C:\eclipse\workspace\SOR\implementation\lib\dom4j-1.6.jar;C:\eclipse\workspace\SOR\implementation\lib\ehcache-1.1.jar;C:\eclipse\workspace\SOR\implementation\lib\hibernate3.jar;C:\eclipse\workspace\SOR\implementation\lib\jta.jar;C:\eclipse\workspace\SOR\implementation\lib\log4j-1.2.9.jar;C:\eclipse\workspace\SOR\implementation\lib\classes12.jar;C:\eclipse\workspace\SOR\implementation\lib\AppParametersUtility.jar;C:\eclipse\workspace\SOR\implementation\lib\sor_request.jar;C:\eclipse\workspace\SOR\implementation\lib\sor_response.jar;C:\eclipse\workspace\SOR\implementation\lib\jakarta-regexp-1.2.jar;C:\eclipse\workspace\SOR\implementation\lib\tiaa-logging.jar;C:\eclipse\workspace\SOR\implementation\lib\commons-lang.jar;C:\tiaaconfigs\appparams;C:\tiaaconfigs\log4j, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\j2sdk1.4.1_02\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.OracleDialect, connection.pool_size=1, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.1_02, java.ext.dirs=C:\j2sdk1.4.1_02\jre\lib\ext, sun.boot.class.path=C:\j2sdk1.4.1_02\jre\lib\rt.jar;C:\j2sdk1.4.1_02\jre\lib\i18n.jar;C:\j2sdk1.4.1_02\jre\lib\sunrsasign.jar;C:\j2sdk1.4.1_02\jre\lib\jsse.jar;C:\j2sdk1.4.1_02\jre\lib\jce.jar;C:\j2sdk1.4.1_02\jre\lib\charsets.jar;C:\j2sdk1.4.1_02\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=org.hibernate.dialect.OracleDialect, sun.cpu.isalist=pentium i486 i386}
18:18:55,432 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
18:18:55,432 DEBUG SessionFactoryObjectFactory:76 - registered: 8a30840106e6ea210106e6ea22480000 (unnamed)
18:18:55,432 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
18:18:55,432 DEBUG SessionFactoryImpl:262 - instantiated session factory
18:18:55,432 INFO SessionFactoryImpl:379 - Checking 0 named queries
18:18:55,510 DEBUG SessionImpl:250 - opened session at timestamp: -9223372036854775808


Top
 Profile  
 
 Post subject: Re: org.hibernate.MappingException: Unknown entity:
PostPosted: Wed Oct 12, 2005 7:13 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Hibernate is an Object Relational Mapping tool. It's not just about doing queries. From looking at your mapping document, I can guess that you haven't done ANY of the many tutorials out there.

The error is thrown because you haven't provided a mapping file for ClientPlanVO.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 11:33 am 
Newbie

Joined: Wed Oct 12, 2005 6:27 pm
Posts: 3
You are absolutely right. Now I added the proper mapping files.
When I execute the query its running perfect and its returning the List.

Since I am selection 2 objects into the list I am not ware how the objects are added into the list.

When I iterate the list and cast it to the mapping objects or to List object its throwing ClassCastException.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 11:48 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
samu wrote:
You are absolutely right. Now I added the proper mapping files.
When I execute the query its running perfect and its returning the List.

Since I am selection 2 objects into the list I am not ware how the objects are added into the list.

When I iterate the list and cast it to the mapping objects or to List object its throwing ClassCastException.


Are you still using the same query ?
Code:
select distinct a2.plan_id as {cp.planId}, a1.client_id as {cp.clientId} from clnt_engmnt a1, clnt_engmnt_plan a2, plan_version a3 where a1.engagement_id = a2.engagement_id and a2.plan_id = a3.plan_id and a3.status=30


If so, where does the cp ? come from ?

The easiest way to figure out what's going on is to inspect the objects from the List in a debugger.

If you're doing something like "SELECT a, b from...." then the list will contain Object[] objects with Object[0] being an "a" object and Object[1] being a "b" object. (Which you would know if you read the documentation.)

This project has execellent documentation. Take a few hours and read it and you will not only save yourself countless headaches and hours of problem resolution, you'll also discover the power it provides and learn new and better ways to use it.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 11:52 am 
Newbie

Joined: Wed Oct 12, 2005 6:27 pm
Posts: 3
Hi Preston,

Thanks for you help. I read the documentation and I fixed this problem.

I appreciate your help.


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

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.