-->
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.  [ 7 posts ] 
Author Message
 Post subject: Errors in named Queries
PostPosted: Mon Jan 30, 2006 8:09 am 
Newbie

Joined: Mon Jan 30, 2006 7:51 am
Posts: 7
Hello,
I always get an HibernateException when loading my Configuration as soon as i include the following NamedQuery:
Code:
<hibernate-mapping>
    <sql-query name="UserProjektVorgabeQuery">
        <return alias="v" class="model.UserProjektVorgabe">
            <return-property name="qnummer"        column="qnummer"/>
            <return-property name="vaterprojekt"   column="vaterprojekt"/>
            <return-property name="projektbereich" column="projektbereich"/>
            <return-property name="vorgabeprojekt" column="defaultarea"/>
        </return>
        SELECT m.qnummer         AS qnummer,
               pb.vaterprojekt   AS vaterprojekt,
               pb.projektbereich AS projektbereich,
               m.default_area    AS defaultarea
          FROM adm_vfm_kr.TBLMITARBEITER      m,
               adm_vfm_kr.TBLBENUTZERGRUPPEN  b,
               adm_vfm_kr.TBLPROJEKT_BEREICHE pb
         WHERE m.benutzergruppe = b.gruppennr
           AND b.vorgabeprojekt = pb.projektbereich
           AND m.qnummer        = :QNUMMER
    </sql-query>
</hibernate-mapping>



My Stacktrace:
Code:
org.hibernate.HibernateException: Errors in named queries: UserProjektVorgabeQuery
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:338)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1164)
        at model.HibernateUtil.init(HibernateUtil.java:18)
        at model.TestKlasse.main(TestKlasse.java:87)


Any suggestions?
I'm using the current HibernateCore Release and my configuration gets parsed correctly when leaving out this named query.
The SQL-Statement itself is also ok.
Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:14 pm 
Newbie

Joined: Mon Jan 30, 2006 7:51 am
Posts: 7
?!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
enable error logging for org.hibernate.impl.SessionFactoryImpl; it'll tel you exactly what the problems were


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 10:02 am 
Newbie

Joined: Mon Jan 30, 2006 7:51 am
Posts: 7
Ok, I did. Here's the Debug/Stacktrace:
Code:
INFO - building session factory
DEBUG - Session factory constructed with filter configurations : {}
DEBUG - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=XXX, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, sun.boot.library.path=C:\XXX\Java\jdk\jre\bin, java.vm.version=1.5.0_02-b09, hibernate.connection.username=XXX, 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=DE, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\XX\Tests\XX\XXX, java.runtime.version=1.5.0_02-b09, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hibernate.current_session_context_class=thread, java.endorsed.dirs=C:\XX\Java\jdk\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOKUME~1\XX\LOKALE~1\Temp\, line.separator=
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, cache.provider_class=org.hibernate.cache.NoCacheProvider, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\XXX\Java\jdk\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\XXXX\XX\Bin;C:\XX\XX\Projects\Bpl\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\XX\XX\jdk\bin;C:\XX\MySQL_50\bin;C:\XX\Java\bin;C:\XX\ANT\bin, java.specification.name=Java Platform API Specification, java.class.version=49.0, hibernate.connection.pool_size=1, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Dokumente und Einstellungen\XXX, connection.password=XXX, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, connection.username=XXX, java.specification.version=1.5, file.encoding=Cp1252, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=false, java.class.path=C:\XX\Tests\XXX\XXX\build\web\WEB-INF\classes;C:\Programmierung\NetBeans_41\enterprise1\config\TagLibraries\JSTL11\standard.jar;C:\Programmierung\NetBeans_41\enterprise1\config\TagLibraries\JSTL11\jstl.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\antlr.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\commons-beanutils.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\commons-digester.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\commons-fileupload.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\commons-logging.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\commons-validator.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\jakarta-oro.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\struts.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\log4j-1.2.13.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\mysql-connector-java-3.1.12-bin.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\antlr-2.7.6rc1.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\asm-attrs.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\asm.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\cglib-2.1.3.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\commons-collections-2.1.1.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\commons-logging-1.0.4.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\dom4j-1.6.1.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\hibernate3.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\jta.jar;C:\Diplomarbeit\Tests\VFMController\Libraries\Hibernate\log4j-1.2.11.jar;C:\Programmierung\NetBeans_41\enterprise1\jakarta-tomcat-5.5.7\common\lib\jsp-api.jar;C:\Programmierung\NetBeans_41\enterprise1\jakarta-tomcat-5.5.7\common\lib\servlet-api.jar, user.name=XXX, hibernate.show_sql=false, current_session_context_class=thread, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Programmierung\Java\jdk\jre, hibernate.connection.url=jdbc:mysql://localhost:3306/testdb, hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=de, connection.pool_size=1, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, hibernate.cglib.use_reflection_optimizer=true, java.version=1.5.0_02, java.ext.dirs=C:\XX\Java\jdk\jre\lib\ext, sun.boot.class.path=C:\XXX\Java\jdk\jre\lib\rt.jar;C:\XXX\Java\jdk\jre\lib\i18n.jar;C:\XXX\Java\jdk\jre\lib\sunrsasign.jar;C:\XXX\Java\jdk\jre\lib\jsse.jar;C:\XXX\Java\jdk\jre\lib\jce.jar;C:\XXX\Java\jdk\jre\lib\charsets.jar;C:\XXX\Java\jdk\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, connection.driver_class=com.mysql.jdbc.Driver, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, connection.url=jdbc:mysql://localhost:3306/testdb, sun.cpu.isalist=, dialect=org.hibernate.dialect.MySQLDialect}
DEBUG - instantiated session factory
DEBUG - Checking 0 named HQL queries
DEBUG - Checking 1 named SQL queries
DEBUG - Checking named SQL query: UserProjektInfoQuery
ERROR - Error in named query: UserProjektInfoQuery
org.hibernate.MappingException: Unknown entity: model.UserProjektInfo
        at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:513)
Initial SessionFactory creation failed.org.hibernate.HibernateException: Errors in named queries: UserProjektInfoQuery
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.init(HibernateUtil.java:21)
        at model.TestKlasse.main(TestKlasse.java:50)
Caused by: org.hibernate.HibernateException: Errors in named queries: UserProjektInfoQuery
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:338)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1164)
        at util.HibernateUtil.init(HibernateUtil.java:17)
        ... 1 more
        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.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:21)
        at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:113)
        at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:409)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:327)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1164)
        at util.HibernateUtil.init(HibernateUtil.java:17)
        at model.TestKlasse.main(TestKlasse.java:50)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 10:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
yep, there it is...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 11:26 am 
Newbie

Joined: Mon Jan 30, 2006 7:51 am
Posts: 7
Code:
DEBUG - Checking 1 named SQL queries
DEBUG - Checking named SQL query: UserProjektInfoQuery
ERROR - Error in named query: UserProjektInfoQuery
org.hibernate.MappingException: Unknown entity: model.UserProjektInfo

Ok, I assume it's because i didn't define an Entity via
Code:
<class name="model.UserProjektInfo" table="tbl_some_table">
    <!-- .. -->
</class>

Ok, sounds reasonable but the thing is: I'd like to "wrap" the (Single-Row)ResultSet of a named Query into a "Pojo" just for VIEWING, not manipulating and storing it again.
So why should i define this Pojo as an entity?

Sorry, I'm new to Hibernate ( and I'm likely to like it ;) ) and following to the Docs I just have to define a named Query and define the Mapping to a Pojo via the <result .. /> within this named query. (as far as I understood).

Thanks so far nevertheless!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 5:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
thats not possible with a native-sql query. both Criteria and HQL have that capability though...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.