[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HHH-5775) Support session filters in DML statements
Jason Clawson (JIRA)
noreply at atlassian.com
Fri Dec 3 19:26:13 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39287#action_39287 ]
Jason Clawson edited comment on HHH-5775 at 12/3/10 6:24 PM:
-------------------------------------------------------------
I have completed an initial test modification to hibernate in order to support this. I only had to modify 2 classes:
- org.hibernate.hql.ast.HqlSqlWalker
-- modified postProcessDML to use the filters from getEnabledFilters()
- org.hibernate.hql.ast.exec.BasicExecutor
-- used parameters.processFilters( sql, session ) to filter the SQL like org.hibernate.loader.Loader does
-- copied the method bindFilterParameterValues from Loader into BasicExecutor
-- call bindFilterParameterValues from execute to bind the filter params prior to binding the rest of the params
I am sure this solution needs modification to account for other situations. I am still hoping the hibernate folks can shed some light on why this wasn't done in the first place.
Once I clean up my solution and do some more testing I will post a patch.
was (Author: jclawson):
I have completed an initial test modification to hibernate in order to support this. I only had to modify 2 classes:
- org.hibernate.hql.ast.HqlSqlWalker
- modified postProcessDML to use the filters from getEnabledFilters()
- org.hibernate.hql.ast.exec.BasicExecutor
- used parameters.processFilters( sql, session ) to filter the SQL like org.hibernate.loader.Loader does
- copied the method bindFilterParameterValues from Loader into BasicExecutor
- call bindFilterParameterValues from execute to bind the filter params prior to binding the rest of the params
I am sure this solution needs modification to account for other situations. I am still hoping the hibernate folks can shed some light on why this wasn't done in the first place.
Once I clean up my solution and do some more testing I will post a patch.
> Support session filters in DML statements
> -----------------------------------------
>
> Key: HHH-5775
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5775
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core, query-hql
> Reporter: Jason Clawson
>
> We are using filters to support multi-tenency, an approach alluded to in this recent blog post: http://in.relation.to/Bloggers/MultitenancyInHibernate. It works create for HQL selects but doesn't work for Updates / Deletes. Looking through the source code, this seems to have been a conscious choice as some comments indicate. If filters are meant to be used for multitenency, this seems to be the wrong choice. I would like to see session filters affect updates and deletes. This seems very logical because if I run the select: SELECT * FROM User which is affected by a filter and returns 2 users, and then execute DELETE FROM User which deletes all the users in the system--- thats not what I would expect to happen.
> I believe this will require modifications to HqlSqlWalker and the ANTLR script sql-gen.g. I am looking into what other modifications are necessary, but I would appreciate it if the Hibernate folks could take a look since they would be most familiar with the code and the decisions behind it.
> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list