[Hibernate-JIRA] Resolved: (HHH-1805) Incorrect query parsing cause NullPointerException
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1805?page=c... ]
Diego Pires Plentz resolved HHH-1805.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
> Incorrect query parsing cause NullPointerException
> --------------------------------------------------
>
> Key: HHH-1805
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1805
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.2.0.cr2
> Reporter: Igor A Tarasov
> Assignee: Diego Pires Plentz
>
> Incorrect HQL query (without AS object) cause NullPointerException
> Incorrect: "select o from MyObject where o.name = ?1"
> Correct: "select o from MyObject as o where o.name = ?1"
> The next code with incorrect query cause NullPointerException:
> em.createQuery("select o from MyObject where o.name = ?1").setParameter(1, "some_name").getResultList();
> java.lang.NullPointerException
> at org.hibernate.hql.ast.tree.IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:195)
> at org.hibernate.hql.ast.tree.IdentNode.resolve(IdentNode.java:85)
> at org.hibernate.hql.ast.tree.DotNode.resolveFirstChild(DotNode.java:139)
> at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:469)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4316)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1211)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4032)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3880)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
> at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:227)
> at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:159)
> at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
> 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:71)
> 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:1612)
> at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:76)
> at org.dicr.isp.data.HibernateDataManager.createConnection(HibernateDataManager.java:696)
--
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
18 years, 7 months
[Hibernate-JIRA] Created: (HHH-2688) HQL: Incorrect join when ordering by property of nullable many-to-one
by Scott Van Wart (JIRA)
HQL: Incorrect join when ordering by property of nullable many-to-one
---------------------------------------------------------------------
Key: HHH-2688
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2688
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Oracle 10gR2
Reporter: Scott Van Wart
Attachments: pojos_and_mappings.zip
I have two tables: Parent and Child. Children may not have a parent. I want to select all children, ordering by parent name:
TABLE parent_table ( parent_id NUMBER PRIMARY KEY, parent_name VARCHAR2(30) NOT NULL );
TABLE child_table ( child_id NUMBER PRIMARY KEY, parent_id REFERENCES parent ON DELETE SET NULL );
So I create the two POJOs and mapping documents (attached). After openSession():
List children = session.createQuery( "from Child c order by c.parent.name" ).list();
I only get back the children with parents, because here's the generated SQL, with an INNER join:
select child0_.child_id as child1_17_, child0_.parent_id as parent2_17_
from child_table child0_, parent_table parent1_
where child0_.parent_id=parent1_.parent_id
order by parent1_.parent_name;
Because parent_id in the child table is nullable, I would expect the generated SQL to be:
select child_id, parent_id
from child_table c LEFT JOIN parent_table p ON c.parent_id = p.parent_id
order by p.parent_name;
I guess a workaround might be to specify the join type explicitly in the HQL, but this default behavior kind of surprised me. Thanks.
--
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
18 years, 7 months
[Hibernate-JIRA] Resolved: (HHH-1902) Alias Problem... Hibernate is replacing our alias at one place but not at another place
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1902?page=c... ]
Diego Pires Plentz resolved HHH-1902.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
> Alias Problem... Hibernate is replacing our alias at one place but not at another place
> ---------------------------------------------------------------------------------------
>
> Key: HHH-1902
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1902
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.0.3, 3.2.1
> Environment: Hibernate 3.0.3
> Database Platform : MSSQL Server 2000
> Reporter: Paras Dhawan
> Assignee: Diego Pires Plentz
> Attachments: testhibernate.rar
>
>
> I have a query which contains a sub query in the select list... I have defined an alias of the sub query as _sqry1 now I am putting an Order By clause in the query.... Order By is on the result of the sub query and I have given the alias of the sub query in the Order By clause
> My Query is which i am giving to Hibernate is
> SELECT (SELECT SUM(_0_ServiceCharge_0_service.chargeAmount) FROM Service AS _0_service , ServiceCharge AS _0_ServiceCharge_0_service WHERE _transportService_Challan = _0_service AND _0_service = _0_ServiceCharge_0_service.service) AS _sqry1 FROM Challan AS _Challan LEFT OUTER JOIN _Challan.transportService AS _transportService_Challan ORDER BY _sqry1
> Now the problem is that Hibernate is replacing my aliases.... it replaced my alias of the sub query from _sqry1 to col_0_0_ .... it replaced this alias in the select list but not in the Order By clause... i.e. it replaced the alias where I defined it but it did not replaced the alias where I used it.... so the place where I am using the alias it is giving an error as undefined alias
> The generated SQL by Hibernate:
> select (select SUM(servicecha3_.ChargeAmount) from Services service2_, ServiceCharges servicecha3_ where transports1_.TransportServiceId=service2_.ServiceId and service2_.ServiceId=servicecha3_.serviceGroupTablePKId) as col_0_0_ from Challans challan0_ left outer join TransportServices transports1_ on challan0_.TransportServiceId=transports1_.TransportServiceId left outer join Services transports1_1_ on transports1_.TransportServiceId=transports1_1_.ServiceId order by _sqry1
> when I manually replaced my alias in the Order By clause then my query run successfully
> Either Hibernate should not replace my alias, even if it is replacing then it must replace all the occurences
> I cannot use criteria, I cannot use named queries, i cannot use native sql because my queries are formed at run time, I have to specify a HQL only... This is bug in Hibernate
> Hibernate version: 3.0.5
> Name and version of the database that I am using:
> MS SQL Server 2000
> Full stack trace of any exception that occurs:
> Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.loader.Loader.doList(Loader.java:2148)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at com.daffodilwoods.framework.utils.HibernateUtil.main(HibernateUtil.java:296)
> Caused by: java.sql.SQLException: [DataDirect][SQLServer JDBC Driver][SQLServer]Invalid column name '_sqry1'.
> at com.ddtek.jdbc.base.BaseExceptions.createException(Unknown Source)
> at com.ddtek.jdbc.base.BaseExceptions.getException(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRPCNonCursorExecuteRequest.submitPrepare(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRPCExecuteRequest.doPrepExec(Unknown Source)
> at com.ddtek.jdbc.sqlserver.tds.TDSRPCExecuteRequest.execute(Unknown Source)
> at com.ddtek.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source)
> at com.ddtek.jdbc.base.BaseStatement.commonExecute(Unknown Source)
> at com.ddtek.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
> at com.ddtek.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> at org.hibernate.loader.Loader.doQuery(Loader.java:662)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.doList(Loader.java:2145)
> ... 8 more
--
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
18 years, 7 months
[Hibernate-JIRA] Created: (HHH-2751) MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()
by S.Schnabl (JIRA)
MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()
----------------------------------------------------------------------------------------------------------------------
Key: HHH-2751
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2751
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1, 3.2.4, 3.2.3, 3.2.2, 3.2.1
Environment: Windows-XP, Jboss 4.2 GA, Hibernate 3.2.1GA, EJB3
Reporter: S.Schnabl
Attachments: Hibernate-TestCase.rar
For more details see the attached testcase. I'm sorry, but in the short of time i only got a testcase for jboss-server 4.2. Please deploy the server.ear from /release-directory and then call the /src/client/TestCaseClient.java.
Explanation:
I have two entities A.class and B.class defined, both inheriting from an common (empty) abstract MappedSuperclass. A and B having a m:n relation between each other. Furthermore there is an PostUpdateListener, which iterates through all properties of updated entities.
Testcase:
Both entities are linked with each (m:n), now i do an update of a simple property of entity A --> MyPostUpdateListener will be called, which iterates through each property of the updated entity(ies). In case of this property was a collection (= property of the m:n relation), the listener furthermore iterates through this collection and get the id of each object in the collection. Doing so will raise following exception :
Caused by: org.hibernate.AssertionFailure: collection [com.qualitype.testcase.server.ejb.entity.EntityB.entitiesOfA] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
... 29 more
Summarized these error will only occur, in case we are inherating from a mappedSuperClass, having a m:n relation and having the listener touching the collection-elements. But these scenario isn'n very uncommon. We are using hibernate-event listener system for auditing-purposes, so you should understand that touching ever (element in the) collectin is necessary for audit-purposes.
Seems for me like a bug. Need this fixed asap ...
--
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
18 years, 7 months
[Hibernate-JIRA] Resolved: (HHH-1579) Hibernate fails after 1500 sessions on client Java5 JVM
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1579?page=c... ]
Diego Pires Plentz resolved HHH-1579.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
Fix Version/s: 3.2.0.cr4
> Hibernate fails after 1500 sessions on client Java5 JVM
> -------------------------------------------------------
>
> Key: HHH-1579
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1579
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.2.0.alpha2
> Environment: Environment: Java 5 on linux 32 and 64 bit version
> Note: by default 64 bit version of JDK is in server mode.
> Reporter: Konstantin Ignatyev
> Assignee: Diego Pires Plentz
> Fix For: 3.2.0.cr4
>
> Attachments: manysessionsTest.tgz
>
>
> There is interesting production grade bug on Linux: if JVM is in client mode then after 1500 sessions Hibernate starts to behave strangely.
> If -server option is used then test passes.
> Repro:
> -untar the content in the hibernate source directory;
> - apply diff to the AllTests.java or simply add line to the class suite.addTest( ManySessionsTest.suite() );
> run test :
> ant -f build-test.xml junit -Dtestpattern=Many*Test -Dvm=client
> this time test fails
> ant -f build-test.xml junit -Dtestpattern=Many*Test -Dvm=server
> now it passes
> The bug affects 3.1 line and is present in the 3.2 trunc
> This is complementary to bug HHH-1293
--
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
18 years, 7 months
[Hibernate-JIRA] Created: (HHH-2832) getting erroneous behavior when specifying alias without column in WHERE
by John Mazzitelli (JIRA)
getting erroneous behavior when specifying alias without column in WHERE
------------------------------------------------------------------------
Key: HHH-2832
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2832
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.3
Reporter: John Mazzitelli
Priority: Minor
This HQL works and generates proper SQL:
SELECT min(d.min) AS baselineMin,
max(d.max) AS baselineMax,
avg(d.value) AS baselineMean,
CURRENT_TIMESTAMP AS computeTime,
d.id.scheduleId AS scheduleId
FROM MeasurementDataNumeric1H d
JOIN d.schedule s
LEFT JOIN s.baseline b
WHERE b IS NULL
AND d.id.timestamp BETWEEN 500 AND 1000
GROUP BY d.id.scheduleId
HAVING d.id.scheduleId IN (SELECT d1.id.scheduleId
FROM MeasurementDataNumeric1H d1
WHERE d1.id.timestamp <= 500
AND d1.id.scheduleId = d.id.scheduleId)
The first condition in the where-clause that is generated looks like this:
where
(
measuremen2_.id is null
)
Now, simply add this line to the beginning of that HQL - just insert it at the top and do NOT change anything else within that main SELECT (you are in effect going to change it so it inserts the selected data that you got from the above HQL):
INSERT INTO MeasurementBaseline (baselineMin,baselineMax,baselineMean,computeTime,scheduleId)
and that first where-condition now looks like this:
where
(
id is null
)
and this causes problems.
Workaround is to change the WHERE clause so it uses "b.id" instead of just "b":
WHERE b.id IS NULL
In case you care, here is the full SQL generated by that original SELECT (as taken from the Eclipse Hibernate Tools Dynamic SQL Preview view):
==============================
SQL #0 types: double, double, double, timestamp, integer
-----------------
select
min(measuremen0_.minvalue) as col_0_0_,
max(measuremen0_.maxvalue) as col_1_0_,
avg(measuremen0_.value) as col_2_0_,
CURRENT_TIMESTAMP as col_3_0_,
measuremen0_.SCHEDULE_ID as col_4_0_
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen0_
inner join
public.ON_MEASUREMENT_SCHEDULE measuremen1_
on measuremen0_.SCHEDULE_ID=measuremen1_.id
left outer join
public.ON_MEASUREMENT_BASELINE measuremen2_
on measuremen1_.id=measuremen2_.SCHEDULE_ID
where
(
measuremen2_.id is null
)
and (
measuremen0_.TIME_STAMP between 500 and 1000
)
group by
measuremen0_.SCHEDULE_ID
having
measuremen0_.SCHEDULE_ID in (
select
measuremen3_.SCHEDULE_ID
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen3_
where
measuremen3_.TIME_STAMP<=500
and measuremen3_.SCHEDULE_ID=measuremen0_.SCHEDULE_ID
)
=====================================
and here is the generated SQL when I make it an INSERT INTO SELECT (you'll notice the HAVING's WHERE clause is also different):
DML #0 tables: public.ON_MEASUREMENT_BASELINE, public.MeasurementData, public.ON_MEASUREMENT_DATA_NUM_1H, public.ON_MEASUREMENT_SCHEDULE
-----------------
insert
into
public.ON_MEASUREMENT_BASELINE
( id, BL_MIN, BL_MAX, BL_MEAN, BL_COMPUTE_TIME, SCHEDULE_ID ) select
nextval ('public.ON_MEASUREMENT_BASELINE_ID_SEQ'),
min(measuremen0_.minvalue) as col_0_0_,
max(measuremen0_.maxvalue) as col_1_0_,
avg(measuremen0_.value) as col_2_0_,
CURRENT_TIMESTAMP as col_3_0_,
measuremen0_.SCHEDULE_ID as col_4_0_
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen0_
inner join
public.ON_MEASUREMENT_SCHEDULE measuremen1_
on measuremen0_.SCHEDULE_ID=measuremen1_.id
left outer join
public.ON_MEASUREMENT_BASELINE measuremen2_
on measuremen1_.id=measuremen2_.SCHEDULE_ID
where
(
id is null
)
and (
measuremen0_.TIME_STAMP between 500 and 1000
)
group by
measuremen0_.SCHEDULE_ID
having
measuremen0_.SCHEDULE_ID in (
select
measuremen3_.SCHEDULE_ID
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen3_
where
measuremen3_.TIME_STAMP<=500
and measuremen3_.SCHEDULE_ID=public.ON_MEASUREMENT_DATA_NUM_1H.SCHEDULE_ID
)
I'm not sure what other information you'll need.
--
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
18 years, 7 months