[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2159) Query that previously worked in 3.2.0CR2 does not work anymore

Jesper Udby (JIRA) noreply at atlassian.com
Fri Apr 20 15:25:04 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26787 ] 

Jesper Udby commented on HHH-2159:
----------------------------------

Hello,

we are in the process of converting the persistence layer of a medium sized application from EJB 2.1 to (Hibernate-) JPA.

In the first iteration the EJBQL was not touched at all - just copied'n'pasted into our JPA "entities".

When done, the hibernate core failed with an NPE in the FromClause class (line 120 - this being the original unmodified 3.2.3 core) when initializing the persistence unit (calling Persistence.createEntityManagerFactory(...)) when any one of 2 different named queries were enabled.

Without repeating the entire object model (which I cannot), I can reproduce the queries that fails:

SELECT l FROM Loan l WHERE l.funding.bond.bondLoanProvider.id = :providerId AND l.disbursementDate <= :currentDate AND (l.loanState.state='ACC' OR l.loanState.state='REA') AND l.funding.fundingTransactions IS EMPTY
SELECT l FROM Loan l WHERE l.funding.bond.bondLoanProvider.id = :providerId AND l.disbursementDate <= :disbursementDate AND (l.loanState.state='ACC' OR l.loanState.state='REA') AND l.funding.fundingTransactions IS NOT EMPTY

My initial fix is to reverse the comparison in line 120 in the original FromClause source - NOT taking Andy's fix into account. The assumption being that the function argument is never null, but the map searched can have null keys.

I cannot yet verify that the query actually works - we are still iterating on the conversion process and we have several different other issues.

But, I can guarantee that "my" fix does not introduce other errors as x.equalsIgnoreCase( y ) == y.equalsIgnoreCase( x ) assuming x and y are both Strings. Assuming y (the function argument) is never null, the latter is more robust...

When I return to my customer on Monday, I will try Andy's fix and report back here.

I do hope this issue will get fixed in an upcoming version, as the "unpacthed" 3.2.3 version simply fails early during initialization, if the queries mentioned are enabled.

Kind Rgds

Jesper Udby

> Query that previously worked in 3.2.0CR2 does not  work anymore
> ---------------------------------------------------------------
>
>                 Key: HHH-2159
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.0.ga
>         Environment: hibernate 3.2.0GA, PostgreSQL 8.1.4 (using build 407 of the JDBC driver).  JDK 1.5.0_06, JBoss 4.0.4GA, Operating system is Fedora Core 5
>            Reporter: Andy Dale
>         Attachments: FromClause.java, FromClause.java.diff, hibernate_testcase.tar.gz, HibernateTestcase.tar.gz, OrignalTest.tar.gz
>
>
> First off i do not know if this bug belongs to the Hibernate3(core) or Hibernate EntityManger branch, but have entered it against core because that is where the exception occurs (in org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements).
> I have a relativley simple entity setup up to test a proof of concept.  Persisting the data to the database is not a problem in the new version 3.2.0.GA, but the problems occurs when trying to perform a query on the persisted data, the very same query works with 3.2.0CR2 but gives a nullPointException in 3.2.0GA.
> I have attached the java source for the entities + session bean (in hibernate_testcase.tar.gz/entities file) and the java class (in hibernate_testcase.tar.gz/service file) that is used to persist and query the data, and because this was only meant to be a proof of concept i have also included the .ear archive as apart from the entity definitions and session bean the only other thing it contains is a JBoss .sar archive which calls the static persist and query methods in the session bean (service test.testcase).  Please note to use the .ear archive you need a datasource called Postgres_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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list