[Hibernate-JIRA] Created: (HHH-5621) NPE (in ReflectHelper.getConstructor) during createQuery without alias with one entity (wich use several tables)
by Félix Gerzaguet (JIRA)
NPE (in ReflectHelper.getConstructor) during createQuery without alias with one entity (wich use several tables)
----------------------------------------------------------------------------------------------------------------
Key: HHH-5621
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5621
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0.CR2
Environment: Gentoo Linux
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Hibernate 3.6.0.CR2
tested DB: PostgreSQL 8.4, HSQLDB 1.8.0.10
Reporter: Félix Gerzaguet
Priority: Minor
Attachments: TestCaseCreateQueryWithoutAliasNPE.jar
During a session.createQuery like:
Query query6 = session.createQuery("select new Something(id, event, dummyField) " +
"from Something" );
A NPE is thrown:
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:343)
at org.hibernate.hql.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:176)
at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:150)
at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:996)
I join an test case.
All versions of hibernate seems affected (from 3.2.6.ga to 3.6.0.RC2).
This is a minor issue since an easy workaround is available: you just have to use an alias to qualifie the properties
For the preceding example, we will have:
Query query3 = session.createQuery("select new Something(sthg.id, sthg.event, sthg.dummyField) " +
"from Something sthg" );
Possible fix:
As described in the testCase, I fix this by a one character fix:
In org.hibernate.hql.ast.HqlSqlWalker in method isNonQualifiedPropertyRef,
change from
if ( fromElements.size() == 1 ) {
to
if ( fromElements.size() >= 1 ) {
This could means that when a property is not qualified, we leave a chance for this property to be found on the first explicit element of the from clause.
I test this fix on the 3.5.5-Final code and I was able to run the test suite without failures.
I can't think of a test case in which this fix could lead to a regression but I'm not an Hibernate Guru so comments are welcome.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 12 months
[Hibernate-JIRA] Created: (HHH-5666) Missing table alias for one column in generated sql
by Jakub Jankowski (JIRA)
Missing table alias for one column in generated sql
---------------------------------------------------
Key: HHH-5666
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5666
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, MySQL
Reporter: Jakub Jankowski
Column 'desc' in generated sql doesn't have table alias 'announceme0_' (unlike the rest of columns) which genereates error while executing.
Genereted sql:
select announceme0_.announcementID as announce1_1_0_,
announceme0_.oceaneqID as oceaneqID1_0_,
announceme0_.fileName as fileName1_0_,
desc as desc1_0_
from test.announcement announceme0_ where announceme0_.announcementID=1
Mapping for the table:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2010-09-01 12:28:56 by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
<class name="all.model.Announcement" table="announcement" catalog="test">
<id name="announcementId" type="int">
<column name="announcementID" />
<generator class="assigned" />
</id>
<property name="oceaneqId" type="java.lang.Integer">
<column name="oceaneqID" />
</property>
<property name="fileName" type="string">
<column name="fileName" length="1024" />
</property>
<property name="desc" type="string">
<column name="desc" length="1024" />
</property>
<set name="routeOnAnnouncements" inverse="true">
<key>
<column name="announcementID" />
</key>
<one-to-many class="all.model.RouteOnAnnouncement" />
</set>
</class>
</hibernate-mapping>
There's no such problem with other tables.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 12 months
[Hibernate-JIRA] Created: (HHH-5737) Error message regarding JNDI binding...how to get rid of it?
by Colbert Philippe (JIRA)
Error message regarding JNDI binding...how to get rid of it?
------------------------------------------------------------
Key: HHH-5737
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5737
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0
Environment: Windows 7, Java 1.6_22
Reporter: Colbert Philippe
I have a very simple environment, not tied to JNDI service. I am simply creating class mapping files for a project and incorporating them into my Hibernate setup.
During initialization, I am getting this error message related to JNDI. Does anybody know how to resolve this error message?
========================================================
21:59:34,971 INFO SettingsFactory: 351 - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
21:59:34,993 INFO SessionFactoryImpl: 200 - building session factory
21:59:35,165 INFO SessionFactoryObjectFactory: 109 - Factory name: Local MySQL
21:59:35,166 INFO NamingHelper: 49 - JNDI InitialContext properties:{}
21:59:35,169 WARN SessionFactoryObjectFactory: 121 - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:75)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:365)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at rally.core.test.HibernateCreateDbTest.testInitialize(HibernateCreateDbTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
21:59:35,180 INFO SchemaExport: 234 - Running hbm2ddl schema export
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 12 months
[Hibernate-JIRA] Created: (HHH-5713) Member of doesn't work with a @ElementCollection of String
by Antonio Goncalves (JIRA)
Member of doesn't work with a @ElementCollection of String
----------------------------------------------------------
Key: HHH-5713
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5713
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.0
Reporter: Antonio Goncalves
Attachments: JavaEE6Devoxx.zip
Also see https://forum.hibernate.org/viewtopic.php?f=1&t=1007606&p=2437844
I have the following @Entity :
{code}
public class Book {
@Id @GeneratedValue
private Long id;
private String title;
private Float price;
private String isbn;
@ElementCollection
@CollectionTable(name = "tags")
private List<String> tags = new ArrayList<String>();
{code}
I use {{@ElementCollection}} to have a list of strings (tags you can add to books). I want to find all the books that have a tag equals to "scifi", so I wrote the following named query :
{code}
SELECT b FROM Book b WHERE 'scifi' member of b.tags
{code}
But here is what I get (with log level at debug) :
{code}
10:53:14,512 DEBUG QueryTranslatorImpl:272 - parse() - HQL: SELECT b FROM org.beginningee6.tutorial.Book b WHERE 'scifi' member of b.tags
10:53:14,527 DEBUG AST:291 - --- HQL AST ---
\-[QUERY] Node: 'query'
+-[SELECT_FROM] Node: 'SELECT_FROM'
| +-[FROM] Node: 'FROM'
| | \-[RANGE] Node: 'RANGE'
| | +-[DOT] Node: '.'
| | | +-[DOT] Node: '.'
| | | | +-[DOT] Node: '.'
| | | | | +-[IDENT] Node: 'org'
| | | | | \-[IDENT] Node: 'beginningee6'
| | | | \-[IDENT] Node: 'tutorial'
| | | \-[IDENT] Node: 'Book'
| | \-[ALIAS] Node: 'b'
| \-[SELECT] Node: 'SELECT'
| \-[IDENT] Node: 'b'
\-[WHERE] Node: 'WHERE'
\-[IN] Node: 'in'
+-[QUOTED_STRING] Node: ''scifi''
\-[IN_LIST] Node: 'inList'
\-[QUERY] Node: 'QUERY'
\-[SELECT_FROM] Node: 'SELECT_FROM'
\-[FROM] Node: 'from'
\-[RANGE] Node: 'RANGE'
\-[DOT] Node: '.'
+-[IDENT] Node: 'b'
\-[IDENT] Node: 'tags'
10:53:14,527 DEBUG ErrorCounter:91 - throwQueryException() : no errors
10:53:14,527 DEBUG HqlSqlBaseWalker:111 - select << begin [level=1, statement=select]
10:53:14,527 DEBUG FromElement:157 - FromClause{level=1} : org.beginningee6.tutorial.Book (b) -> book0_
10:53:14,527 DEBUG FromReferenceNode:74 - Resolved : b -> book0_.id
10:53:14,527 DEBUG HqlSqlBaseWalker:111 - select << begin [level=2, statement=select]
10:53:14,543 DEBUG FromElementFactory:131 - createFromElementInSubselect() : path = b.tags
10:53:14,543 DEBUG PathHelper:69 - parsePath() : b.tags -> [ ( . b tags ) ]
10:53:14,543 DEBUG FromReferenceNode:74 - Resolved : b -> book0_.id
10:53:14,543 DEBUG DotNode:613 - getDataType() : tags -> org.hibernate.type.BagType(org.beginningee6.tutorial.Book.tags)
10:53:14,543 DEBUG FromElement:157 - FromClause{level=2} : null (no alias) -> tags1_
10:53:14,543 DEBUG FromClause:368 - addCollectionJoinFromElementByPath() : b.tags -> tags
10:53:14,543 DEBUG DotNode:306 - dereferenceCollection() : Created new FROM element for b.tags : tags tags1_
10:53:14,543 DEBUG FromReferenceNode:74 - Resolved : b.tags -> .
10:53:14,543 DEBUG FromElementFactory:164 - createFromElementInSubselect() : b.tags -> tags tags1_
10:53:14,543 DEBUG HqlSqlBaseWalker:117 - select : finishing up [level=2, statement=select]
10:53:14,543 DEBUG HqlSqlWalker:620 - processQuery() : ( SELECT ( FromClause{level=2} tags tags1_ ) )
10:53:14,543 DEBUG HqlSqlWalker:863 - Derived SELECT clause created.
10:53:14,543 DEBUG SyntheticAndFactory:94 - Using unprocessed WHERE-fragment [book0_.id=tags1_.Book_id]
10:53:14,543 DEBUG SyntheticAndFactory:125 - Using processed WHERE-fragment [book0_.id=tags1_.Book_id]
10:53:14,543 DEBUG QueryNode:74 - getWhereClause() : Creating a new WHERE clause...
10:53:14,543 DEBUG HqlSqlBaseWalker:123 - select >> end [level=2, statement=select]
10:53:14,543 DEBUG HqlSqlBaseWalker:117 - select : finishing up [level=1, statement=select]
10:53:14,543 DEBUG HqlSqlWalker:620 - processQuery() : ( SELECT ( {select clause} book0_.id ) ( FromClause{level=1} ) ( WHERE ( in 'scifi' ( inList ( SELECT {derived select clause} ( FromClause{level=2} tags tags1_ ) ( WHERE ( {theta joins} book0_.id=tags1_.Book_id ) ) ) ) ) ) )
10:53:14,543 DEBUG JoinProcessor:179 - Using FROM fragment [Book book0_]
10:53:14,543 DEBUG HqlSqlBaseWalker:123 - select >> end [level=1, statement=select]
10:53:14,559 DEBUG AST:258 - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (tags,Book)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'book0_.id as id0_' {alias=b, className=org.beginningee6.tutorial.Book, tableAlias=book0_}
| \-[SQL_TOKEN] SqlFragment: 'book0_.contentLanguage as contentL2_0_, book0_.description as descript3_0_, book0_.illustrations as illustra4_0_, book0_.isbn as isbn0_, book0_.nbOfPage as nbOfPage0_, book0_.price as price0_, book0_.title as title0_'
+-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[b], fromElementByTableAlias=[book0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'Book book0_' FromElement{explicit,collection join,not a fetch join,fetch non-lazy properties,classAlias=b,role=null,tableName=Book,tableAlias=book0_,origin=null,columns={,className=org.beginningee6.tutorial.Book}}
\-[WHERE] SqlNode: 'WHERE'
\-[IN] InLogicOperatorNode: 'in'
+-[QUOTED_STRING] LiteralNode: ''scifi''
\-[IN_LIST] SqlNode: 'inList'
\-[SELECT] QueryNode: 'SELECT' querySpaces (tags,Book)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
+-[FROM] FromClause: 'from' FromClause{level=2, fromElementCounter=0, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[tags1_], fromElementsByPath=[], collectionJoinFromElementsByPath=[b.tags], impliedElements=[]}
| \-[FROM_FRAGMENT] ImpliedFromElement: 'tags tags1_' ImpliedFromElement{implied,collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=org.beginningee6.tutorial.Book.tags,tableName={none},tableAlias=tags1_,origin=Book book0_,columns={,className=null}}
\-[WHERE] SqlNode: 'WHERE'
\-[THETA_JOINS] SqlNode: '{theta joins}'
\-[SQL_TOKEN] SqlFragment: 'book0_.id=tags1_.Book_id'
10:53:14,574 DEBUG ErrorCounter:91 - throwQueryException() : no errors
10:53:14,574 ERROR PARSER:56 - <AST>:0:0: unexpected end of subtree
10:53:14,574 DEBUG ErrorCounter:51 - <AST>:0:0: unexpected end of subtree
<AST>:0:0: unexpected end of subtree
at org.hibernate.hql.antlr.SqlGeneratorBase.selectClause(SqlGeneratorBase.java:523)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:175)
at org.hibernate.hql.antlr.SqlGeneratorBase.parenSelect(SqlGeneratorBase.java:3438)
at org.hibernate.hql.antlr.SqlGeneratorBase.inList(SqlGeneratorBase.java:3315)
at org.hibernate.hql.antlr.SqlGeneratorBase.exoticComparisonExpression(SqlGeneratorBase.java:3158)
at org.hibernate.hql.antlr.SqlGeneratorBase.comparisonExpr(SqlGeneratorBase.java:1297)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:910)
at org.hibernate.hql.antlr.SqlGeneratorBase.whereExpr(SqlGeneratorBase.java:768)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:191)
at org.hibernate.hql.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:119)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:238)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
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.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:547)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:411)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at org.beginningee6.tutorial.BookTest.initEntityManager(BookTest.java:42)
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:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
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:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
10:53:14,590 ERROR PARSER:56 - <AST>:0:0: expecting "from", found '<ASTNULL>'
10:53:14,590 DEBUG ErrorCounter:51 - <AST>:0:0: expecting "from", found '<ASTNULL>'
<AST>:0:0: expecting "from", found '<ASTNULL>'
at antlr.TreeParser.match(TreeParser.java:68)
at org.hibernate.hql.antlr.SqlGeneratorBase.from(SqlGeneratorBase.java:570)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:177)
at org.hibernate.hql.antlr.SqlGeneratorBase.parenSelect(SqlGeneratorBase.java:3438)
at org.hibernate.hql.antlr.SqlGeneratorBase.inList(SqlGeneratorBase.java:3315)
at org.hibernate.hql.antlr.SqlGeneratorBase.exoticComparisonExpression(SqlGeneratorBase.java:3158)
at org.hibernate.hql.antlr.SqlGeneratorBase.comparisonExpr(SqlGeneratorBase.java:1297)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:910)
at org.hibernate.hql.antlr.SqlGeneratorBase.whereExpr(SqlGeneratorBase.java:768)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:191)
at org.hibernate.hql.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:119)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:238)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
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.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:547)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:411)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at org.beginningee6.tutorial.BookTest.initEntityManager(BookTest.java:42)
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:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
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:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
10:53:14,621 DEBUG QueryTranslatorImpl:241 - HQL: SELECT b FROM org.beginningee6.tutorial.Book b WHERE 'scifi' member of b.tags
10:53:14,621 DEBUG QueryTranslatorImpl:242 - SQL: select book0_.id as id0_, book0_.contentLanguage as contentL2_0_, book0_.description as descript3_0_, book0_.illustrations as illustra4_0_, book0_.isbn as isbn0_, book0_.nbOfPage as nbOfPage0_, book0_.price as price0_, book0_.title as title0_ from Book book0_ where 'scifi' in (select )
10:53:14,621 DEBUG SessionFactoryImpl:557 - Checking 0 named SQL queries
10:53:14,621 ERROR SessionFactoryImpl:422 - Error in named query: findAllScifiBooks
org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT b FROM org.beginningee6.tutorial.Book b WHERE 'scifi' member of b.tags]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
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.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:547)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:411)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at org.beginningee6.tutorial.BookTest.initEntityManager(BookTest.java:42)
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:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
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:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
{code}
Attached is the entity and the unit test that makes it break. The Maven project uses GlassFish (EclipseLink) by default, so you can make it run using {{mvn -Pjboss test}}. Also you need the Derby database running (I'm not using an inmemory DB for this test)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 12 months
[Hibernate-JIRA] Created: (HHH-3524) setFetchMode ignored if using createCriteria
by Peter Weemeeuw (JIRA)
setFetchMode ignored if using createCriteria
--------------------------------------------
Key: HHH-3524
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3524
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5, Oracle 8
Reporter: Peter Weemeeuw
Hi,
It seems that criteria.setFetchMode gets ignored if you combine it with createCriteria to add a restriction.
This works as expected:
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
But in this case the join doesn't happen (and I get a LazyInstantiationException further on).
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
c.createCriteria("menuItemSubscriptions").add(
Restrictions.eq("location", "B")
);
This does not happen if I set lazy="false" in the mappings
file.
Regards,
Peter
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 12 months