[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159?page=c...
]
Jesper Udby commented on HHH-2159:
----------------------------------
One more comment from here:
Although my and Andy's fix removes the NPE, the query being generated is bad.
E.g.
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
becomes (I've changes the aliases for readability)
select
l.UUID as UUID6_,
l.CASHPRINCIPAL as CASHPRIN2_6_,
l.DISBURSEMENTDATE as DISBURSE3_6_,
l.FIRSTSETTLINGDATE as FIRSTSET4_6_,
l.ID as ID6_,
l.LOANRETAILER_UUID as LOANRET11_6_,
l.LOANSTATE_UUID as LOANSTATE12_6_,
l.LOANTYPE as LOANTYPE6_,
l.NUMBEROFSETTLINGPERIODS as NUMBEROF7_6_,
l.PAYMENTFRACTION as PAYMENTF8_6_,
l.REQUESTEDAMOUNT as REQUESTE9_6_,
l.SETTLINGRULE_UUID as SETTLIN10_6_
from
LOAN l,
BUSINESSDATE bd,
FUNDING f,
BOND b,
LOANPROVIDER lp,
LOANSTATE ls
where
lp.ID=:providerId
and b.BONDLOANPROVIDER_UUID=lp.UUID
and f.BOND_ISIN=b.ISIN
and l.UUID=f.LOAN_UUID
and l.LOANSTATE_UUID=ls.UUID
and bd.ISACTIVE='Y'
and l.DISBURSEMENTDATE<=bd.BUSINESSDATE
and (ls.STATE='ACC' or ls.STATE='REA')
and not (exists (select f.UUID from FUNDING f))
The last statemen is crazy - I've rewritten it as a native query as follows (oracle):
select
l.*
from
LOAN l,
BUSINESSDATE bd,
FUNDING f,
BOND b,
LOANPROVIDER lp,
LOANSTATE ls,
FUNDINGTRANSACTIONSFUNDINGS ftx
where
lp.ID=:providerId
and b.BONDLOANPROVIDER_UUID=lp.UUID
and f.BOND_ISIN=b.ISIN
and l.UUID=f.LOAN_UUID
and l.LOANSTATE_UUID=ls.UUID
and bd.ISACTIVE='Y'
and l.DISBURSEMENTDATE<=bd.BUSINESSDATE
and (ls.STATE='ACC' or ls.STATE='REA')
and f.UUID = ftx.FUNDINGS_UUID (+)
and ftx.FUNDINGTRANSACTIONS_UUID is null
It works - but there seems to be an error in the JPA-QL parser.
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira