[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2530?page=c...
]
SK updated HHH-2530:
--------------------
Attachment: filter.sql
Response.hbm.xml
Request.hbm.xml
This is my test for the filter...
Please have a look at how the useridFilter can be enabled for a join query as below
public void testRequest() {
Session session = factory.openSession();
Transaction ts = session.beginTransaction();
session.enableFilter("useridFilter").setParameter("userid",
"danny");
List list = session.createQuery("select req from Response res join res.request
req").list();
Iterator result = list.iterator();
while (result.hasNext()) {
Request req = (Request) result.next();
logger.debug(req.getTxnid() + " " + req.getUserid()+" : " +
req.getChecktype());
}
ts.commit();
session.close();
}
Here is the output
there is no trace of criteria involving userid when I enable show_sql option
[junit] Running com.hibernate.test.filter.orm.RequestFilterTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.34 sec
[junit] Testsuite: com.hibernate.test.filter.orm.RequestFilterTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.34 sec
[junit] ------------- Standard Output ---------------
[junit] org.hibernate.tool.hbm2ddl.SchemaUpdate ERROR Unsuccessful: alter table
RESPONSE add constraint FK1A5D0441F4EBC70D foreign key (TXNID) references REQUEST
[junit] org.hibernate.tool.hbm2ddl.SchemaUpdate ERROR ORA-02275: such a referential
constraint already exists in the table
[junit] au.com.mbf.pvm.services.saclient.RetrieveReportRequestClient DEBUG Buffering
enabled
[junit] org.hibernate.jdbc.JDBCContext DEBUG after transaction begin
[junit] Hibernate:
[junit] select
[junit] request1_.TXNID as TXNID0_,
[junit] request1_.USERID as USERID0_,
[junit] request1_.CHECKTYPE as CHECKTYPE0_
[junit] from
[junit] RESPONSE response0_
[junit] inner join
[junit] REQUEST request1_
[junit] on response0_.TXNID=request1_.TXNID
[junit] au.com.mbf.pvm.AbstractTest DEBUG 1 park : CREDIT
[junit] au.com.mbf.pvm.AbstractTest DEBUG 2 danny : POLICE
[junit] au.com.mbf.pvm.AbstractTest DEBUG 3 dam : REF
[junit] au.com.mbf.pvm.AbstractTest DEBUG 4 dam : REF
[junit] org.hibernate.jdbc.JDBCContext DEBUG before transaction completion
[junit] org.hibernate.jdbc.JDBCContext DEBUG after transaction completion
[junit] org.hibernate.jdbc.JDBCContext DEBUG after transaction completion
It returns four records, it should have returned only one where the user id was
'danny', if the filter was working.
Have a look at Request.hbm.xml for my filter definition and filter condition.
I tried putting USERID = :userid as well as :userid = USERID as suggested in chapter 17 of
the Hibernate 3 documentation regarding filter.
Filter and Join together BUG -attachments included for example of
reproduction
------------------------------------------------------------------------------
Key: HHH-2530
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2530
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.0.cr2
Environment: 3.2.0, Oracle 9
Reporter: SK
Attachments: filter.sql, Request.hbm.xml, Response.hbm.xml
Select a, b from
TableA, TableB
where TableA.id=TableB.id
if i enable a filter, the query above works
but when doing so with join it fails
select a,b
from TableA join TableB
if i try to enable filter now, it will fail
--
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