[Hibernate-JIRA] Created: (HHH-3128) NullPointerException while building SessionFactory when using native sql query for loading many-to-many mapped collections
by Juergen Denzel (JIRA)
NullPointerException while building SessionFactory when using native sql query for loading many-to-many mapped collections
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-3128
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3128
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6, 3.2.5
Environment: Hibernate 3.2.6
Reporter: Juergen Denzel
Attachments: src.zip
Hi,
I am trying to load a many-to-many mapped collection using a sql query like this:
<sql-query name="loadItems">
<load-collection alias="item" role="test.Test.items"/>
select {item.*} from Items item where item.id = :id
</sql-query>
This always fails due to a NullPointerException:
java.lang.NullPointerException
at org.hibernate.loader.custom.sql.SQLQueryParser.resolveProperties(SQLQueryParser.java:182)
at org.hibernate.loader.custom.sql.SQLQueryParser.resolveCollectionProperties(SQLQueryParser.java:135)
at org.hibernate.loader.custom.sql.SQLQueryParser.substituteBrackets(SQLQueryParser.java:98)
at org.hibernate.loader.custom.sql.SQLQueryParser.process(SQLQueryParser.java:51)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:110)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at test.HibernateTest.testSessionFactory(HibernateTest.java:18)
I provided a very simple TestCase + Mappings to illustrate the problem. The exception does not occur for one-to-many mappings.
Just for your information, we need this functionality in order to deal with DB2 problems we have.
I ran this TestCase against 3.2.5 and 3.2.6 and both failed.
Thanks.
Juergen Denzel
--
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
16 years, 12 months
[Hibernate-JIRA] Created: (HHH-3148) Exception thrown by debug trace code: ComponentType toLoggableString
by Pete Geraghty (JIRA)
Exception thrown by debug trace code: ComponentType toLoggableString
--------------------------------------------------------------------
Key: HHH-3148
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3148
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6.ga
HibernateAnnotations 3.3.0.ga
Oracle 10g Express Edition
Reporter: Pete Geraghty
Priority: Minor
Attachments: ToLoggableStringExample.txt
The method toLoggableString in ComponentType is used to provide tracing output when running with log level DEBUG. In some circumstances it throws a ClassCastException.
This is not a good idea in tracing code and obscures underlying problems.
In my case the underlying problem was a previous incorrect call to set a parameter value in a query. I saw that previous JIRA issues have mentioned this ClassCastException as a side effect of other underlying problems - it is a distraction and time-waster.
Lines 375-378 read:
EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
if ( entityMode == null ) {
throw new ClassCastException( value.getClass().getName() );
}
A better solution would be to just us String.valueOf
EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
if ( entityMode == null ) {
return String.valueOf(value);
}
Another possibility would be to concatenate some diagnostic message with String.valueOf, but personally I don't think that be helpful.
Stack trace is:
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377)
at org.hibernate.pretty.Printer.toString(Printer.java:76)
at org.hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:277)
at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:210)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46)
at hib.example.EntityWithEmbeddable.main(EntityWithEmbeddable.java:44)
Example code for the classes and schema to reproduce is pasted into the attachment.
--
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
16 years, 12 months
[Hibernate-JIRA] Created: (HHH-3785) HQL parser not throwing error for unmatched parantheses
by Amaresh wakkar (JIRA)
HQL parser not throwing error for unmatched parantheses
-------------------------------------------------------
Key: HHH-3785
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3785
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Sybase ASE 12, Windows XP SP2
Reporter: Amaresh wakkar
I have following query which I would have expected HQL parser to throw QuerySyntaxException:unexpected token.
================================
from WebAuditLog wal where wal.tmstampLastModified >= convert(date, '18-FEB-09', 111)
and wal.tmstampLastModified <= convert(date, '18-FEB-09', 111))
and wal.sourceId = 'I'
order by wal.client.clientId, wal.tmstampLastModified
====================================
The problem with this query is that on Line#2, there is a redundant unmatched right parantheses i.e. ')' . Ideally this should have been reported as Query syntax exception by HQL parser. Unfortunately, what HQL parses does is
1. ignores everything beyond that errorneous right parantheses
2. Executes such terminated query and returns results which gives impression to user that query is syntactically valid and errors must be either with data or logic of query.
Workaround:
In absensce of HQL parses throwing error, we must ensure that the HQL is correctly written by reviewing it carefully.
Steps to replicate:
1.Create any table which has 2 or 3 columns
2. Try writing a HQL which uses parantheses e.g. functions like convert etc. Add an extra right parantheses at the end of such function's closing right parantheses
3. add additional where clause filtering criteria after step-2
4. Execute the query.
5. In the result you would notice that the where clause criteria mentioned in step-3 is ignored and query is executed as if the query terminated at step-2
I have done a quick search through existing bugs but couldn't find any matching right away so reporting it here.
Hope it helps to make Hibernate HQL parser even more robust
Thanks and regards,
Amaresh Wakkar
--
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
16 years, 12 months
[Hibernate-JIRA] Created: (HHH-3689) NPE when using composite-map-key and composite-element together in a map
by Jason Maskell (JIRA)
NPE when using composite-map-key and composite-element together in a map
------------------------------------------------------------------------
Key: HHH-3689
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3689
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: 3.3.1, MySQL 5
Reporter: Jason Maskell
When trying to get a composite map key working with my composite element class, I ran into this issue. I've seen it reported in a couple of other places since August 08, so it's been around for a while.
<map name="inventory" table="capo_inventory">
<key column="capo_id"/>
<composite-map-key class="ItemCountKey">
<key-many-to-one name="item" column="item_id" class="Item"/>
<key-property name="quality" type="int" column="quality" />
</composite-map-key>
<composite-element class="ItemCount">
<many-to-one name="item" class="com.tamedtornado.data.Item"
formula="item_id" />
<property name="quality" formula="quality" type="int" />
<property name="count" type="int" />
</composite-element>
</map>
This mapping causes this error (root cause):
Caused by: java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:287)
at org.hibernate.util.StringHelper.qualify(StringHelper.java:301)
at org.hibernate.loader.JoinWalker.walkCompositeElementTree(JoinWalker.java:522)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:333)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:278)
at org.hibernate.loader.collection.BasicCollectionJoinWalker.<init>(BasicCollectionJoinWalker.java:70)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:76)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:63)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:54)
at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingCollectionInitializer(BatchingCollectionInitializer.java:115)
at org.hibernate.persister.collection.BasicCollectionPersister.createCollectionInitializer(BasicCollectionPersister.java:320)
at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:563)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:326)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 65 more
It's quite easy to debug, but I have no idea what it's supposed to be doing, so have no idea how to fix it. The String[] cols parameter passed into walkCompositeElementTree has two nulls in it, which causes the NPE later in the stack. I hope this is easily reproducible, as I'm going to have to write some really grodey code now that I can't easily find my object by those two parameters. :)
--
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
17 years
[Hibernate-JIRA] Created: (HHH-3704) Criteria Query on property of sandwich-like @MappedSuperclass fails. HQL works
by Christian kalkhoff (JIRA)
Criteria Query on property of sandwich-like @MappedSuperclass fails. HQL works
------------------------------------------------------------------------------
Key: HHH-3704
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3704
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.3.1
Environment: hibernate 3.3.1, mysql 5.0.45
Reporter: Christian kalkhoff
Priority: Minor
I have a hierarchy of @MappedSuperclasses, in my case:
@MappedSuperclass class BaseEntity{...}
@MappedSuperclass class NamedBaseEntity extends BaseEntity {...}
@Entity class ConcreteEntity extends NamedBaseEntity {...}
@Entity class AggregatingOtherEntity extends NamedBaseEntity {
ConcreteEntity concreteEntity;
}
BaseEntity holds property "id", NamedBaseEntity holds property "name". ConcreteEntity might have property "moonphase".
If I create a Criteria search expression on AggregatingOtherEntity like
eq("concreteEntity.id", 1L)
that works.
eq("concreteEntity.moonphase", "half decending") works either.
BUT
like("concreteEntity.name", "foobar")
raises QueryException:
org.hibernate.QueryException: could not resolve property: concreteEntity.name of: AggregatingOtherEntity
org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:67)
org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:82)
org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:54)
org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1377)
org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:457)
org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:417)
org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:68)
org.hibernate.criterion.LogicalExpression.toSqlString(LogicalExpression.java:62)
org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:357)
org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:113)
org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:91)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1577)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
[...]
If I refactor the Criteria search to plain HQL (From AggregatingOtherEntity Where concreteEntity.name like 'half decending') it works. So there is a workaround.
--
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
17 years