-->
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.  [ 1 post ] 
Author Message
 Post subject: Exception on createQuery
PostPosted: Wed Jun 13, 2007 6:27 am 
Newbie

Joined: Wed Jun 13, 2007 5:29 am
Posts: 1
Hello,
I don't succeed (see exceptions) in using session.createQuery. I tried with the "antlr" way and the "classic" way (see the applicationContext.xml). I tried the 1.5 JVM from Sun in 5.0 and 1.4 mode.

Any idea?
Thanks

Extract of Maven2 dependencies:
• antlr-2.7.6
• hibernate-3.2.1.ga
• spring-hibernate3-2.0
• spring-2.0
• postgresql-8.2-504.jdbc3

Hibernate version: hibernate-3.2.1.ga

Mapping documents: fr/paris/atexo/epm/noyau/persistance/EpmTRefNature.hbm.xml is
Quote:
<hibernate-mapping>
<class name="fr.paris.atexo.epm.noyau.persistance.EpmTRefNature" table="epm__t_ref_nature" schema="public">
<id name="idNature" type="int">
<column name="id_nature" />
<generator class="sequence">
<param name="sequence">epm__t_ref_nature_id_nature_seq</param>
</generator>
</id>
<property name="acronyme" type="string">
<column name="acronyme" length="99" />
</property>
<property name="libelle" type="string">
<column name="libelle" length="99" />
</property>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
EpmTRefNature epmTRefNature;
epmTRefNature = (EpmTRefNature) session.get(EpmTRefNature.class, new Integer("2"));
String queryString = "FROM EpmTRefNature";
Query query =  session.createQuery(queryString); //the exception is thrown here

ArrayList arrayList = new ArrayList(query.list());
tx.commit();



Spring ApplicationContext.xml:
Quote:
<bean id="myDataSourceTestUnitaireTarget" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432"/>
<property name="username" value="*"/>
<property name="password" value="*"/>
</bean>

<!-- Configuration de développement, traces requêtes SQL -->
<bean id="myDataSourceTestUnitaire" class="com.p6spy.engine.spy.P6DataSource" destroy-method="close">
<constructor-arg>
<ref local="myDataSourceTestUnitaireTarget"/>
</constructor-arg>
</bean>

<!-- Définition de la fabrique hibernate3 -->
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSourceTestUnitaire"/>
<property name="mappingResources">
<list>
<value>fr/paris/atexo/epm/noyau/persistance/EpmTRefNature.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<!-- <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop> -->
</props>
</property>
</bean>

<!-- Injection de la fabrique hibernate dans le bean IGRMReferentielNature -->
<bean id="gRMReferentielNature" class="fr.paris.atexo.epm.noyau.metier.GRMReferentielNatureImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
</beans>



Full stack trace of any exception that occurs:
(using hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory)
Quote:
org.hibernate.QueryException: query must begin with SELECT or FROM: FROM EpmTRefNature [FROM EpmTRefNature]
at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:83)
at org.hibernate.hql.classic.PreprocessingParser.end(PreprocessingParser.java:121)
at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:29)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:192)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:168)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at fr.paris.atexo.epm.noyau.metier.GRMReferentielNatureImpl.lister(GRMReferentielNatureImpl.java:119)
at fr.paris.atexo.epm.noyau.metier.TestGRMReferentielNature.testLister(TestGRMReferentielNature.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


(using org.hibernate.hql.ast.ASTQueryTranslatorFactory)
Quote:
line 1:1: unexpected token: FROM EpmTRefNature
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:171)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:248)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at fr.paris.atexo.epm.noyau.metier.GRMReferentielNatureImpl.lister(GRMReferentielNatureImpl.java:119)
at fr.paris.atexo.epm.noyau.metier.TestGRMReferentielNature.testLister(TestGRMReferentielNature.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Name and version of the database you are using: postgresql 8.2.4

Debug level all log excerpt:
(using hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory)
Quote:
DEBUG - SessionImpl.<init>(220) | opened session at timestamp: 11817259954
DEBUG - JDBCTransaction.begin(54) | begin
DEBUG - ConnectionManager.openConnection(415) | opening JDBC connection
DEBUG - JDBCTransaction.begin(59) | current autocommit status: true
DEBUG - JDBCTransaction.begin(62) | disabling autocommit
DEBUG - JDBCContext.afterTransactionBegin(210) | after transaction begin
DEBUG - DefaultLoadEventListener.proxyOrLoad(171) | loading entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - DefaultLoadEventListener.doLoad(332) | attempting to resolve: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - DefaultLoadEventListener.doLoad(369) | object not resolved in any cache: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractEntityPersister.load(2985) | Fetching entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - Loader.loadEntity(1843) | loading entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractBatcher.logOpenPreparedStatement(358) | about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - AbstractBatcher.log(393) | select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?
DEBUG - AbstractBatcher.getPreparedStatement(476) | preparing statement
DEBUG - NullableType.nullSafeSet(80) | binding '2' to parameter: 1
1181725995451|1|15|statement|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - AbstractBatcher.logOpenResults(374) | about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - Loader.doQuery(682) | processing result set
1181725995454|0|15|result|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - Loader.doQuery(687) | result set row: 0
DEBUG - Loader.getRow(1164) | result row: EntityKey[fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - Loader.loadFromResultSet(1346) | Initializing object from ResultSet: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractEntityPersister.hydrate(1981) | Hydrating entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - NullableType.nullSafeGet(122) | returning 'SERVICES' as column: acronyme6_0_
DEBUG - NullableType.nullSafeGet(122) | returning 'services' as column: libelle6_0_
1181725995470|-1||resultset|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2|acronyme6_0_ = SERVICES, libelle6_0_ = services
1181725995470|0|15|result|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - Loader.doQuery(709) | done processing result set (1 rows)
DEBUG - AbstractBatcher.logCloseResults(381) | about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - AbstractBatcher.logClosePreparedStatement(366) | about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - AbstractBatcher.closePreparedStatement(525) | closing statement
DEBUG - Loader.initializeEntitiesAndCollections(839) | total objects hydrated: 1
DEBUG - TwoPhaseLoad.initializeEntity(107) | resolving associations for [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - TwoPhaseLoad.initializeEntity(206) | done materializing entity [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - StatefulPersistenceContext.initializeNonLazyCollections(748) | initializing non-lazy collections
DEBUG - Loader.loadEntity(1874) | done entity load
DEBUG - GRMReferentielNatureImpl.lister(116) | l'objet obtenu a le libelle services
DEBUG - QueryPlanCache.getHQLQueryPlan(70) | unable to locate HQL query plan in cache; generating (FROM EpmTRefNature)
DEBUG - QueryTranslatorImpl.compile(190) | compiling query


(using org.hibernate.hql.ast.ASTQueryTranslatorFactory)
Quote:
DEBUG - SessionImpl.<init>(220) | opened session at timestamp: 11817262606
DEBUG - JDBCTransaction.begin(54) | begin
DEBUG - ConnectionManager.openConnection(415) | opening JDBC connection
DEBUG - JDBCTransaction.begin(59) | current autocommit status: true
DEBUG - JDBCTransaction.begin(62) | disabling autocommit
DEBUG - JDBCContext.afterTransactionBegin(210) | after transaction begin
DEBUG - DefaultLoadEventListener.proxyOrLoad(171) | loading entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - DefaultLoadEventListener.doLoad(332) | attempting to resolve: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - DefaultLoadEventListener.doLoad(369) | object not resolved in any cache: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractEntityPersister.load(2985) | Fetching entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - Loader.loadEntity(1843) | loading entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractBatcher.logOpenPreparedStatement(358) | about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - AbstractBatcher.log(393) | select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?
DEBUG - AbstractBatcher.getPreparedStatement(476) | preparing statement
DEBUG - NullableType.nullSafeSet(80) | binding '2' to parameter: 1
1181726260741|1|15|statement|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - AbstractBatcher.logOpenResults(374) | about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - Loader.doQuery(682) | processing result set
1181726260744|0|15|result|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - Loader.doQuery(687) | result set row: 0
DEBUG - Loader.getRow(1164) | result row: EntityKey[fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - Loader.loadFromResultSet(1346) | Initializing object from ResultSet: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - AbstractEntityPersister.hydrate(1981) | Hydrating entity: [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - NullableType.nullSafeGet(122) | returning 'SERVICES' as column: acronyme6_0_
DEBUG - NullableType.nullSafeGet(122) | returning 'services' as column: libelle6_0_
1181726260778|-1||resultset|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2|acronyme6_0_ = SERVICES, libelle6_0_ = services
1181726260778|0|15|result|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=?|select epmtrefnat0_.id_nature as id1_6_0_, epmtrefnat0_.acronyme as acronyme6_0_, epmtrefnat0_.libelle as libelle6_0_ from public.epm__t_ref_nature epmtrefnat0_ where epmtrefnat0_.id_nature=2
DEBUG - Loader.doQuery(709) | done processing result set (1 rows)
DEBUG - AbstractBatcher.logCloseResults(381) | about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - AbstractBatcher.logClosePreparedStatement(366) | about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - AbstractBatcher.closePreparedStatement(525) | closing statement
DEBUG - Loader.initializeEntitiesAndCollections(839) | total objects hydrated: 1
DEBUG - TwoPhaseLoad.initializeEntity(107) | resolving associations for [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - TwoPhaseLoad.initializeEntity(206) | done materializing entity [fr.paris.atexo.epm.noyau.persistance.EpmTRefNature#2]
DEBUG - StatefulPersistenceContext.initializeNonLazyCollections(748) | initializing non-lazy collections
DEBUG - Loader.loadEntity(1874) | done entity load
DEBUG - GRMReferentielNatureImpl.lister(116) | l'objet obtenu a le libelle services
DEBUG - QueryPlanCache.getHQLQueryPlan(70) | unable to locate HQL query plan in cache; generating (FROM EpmTRefNature)
DEBUG - QueryTranslatorImpl.parse(246) | parse() - HQL: FROM EpmTRefNature
ERROR - ErrorCounter.reportError(33) | line 1:1: unexpected token: FROM EpmTRefNature
DEBUG - ErrorCounter.reportError(28) | line 1:1: unexpected token: FROM EpmTRefNature


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

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.