[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-3938) One-To-One Filter Applied, Non-Lazy Fetch Problem
Sandeep Vaid (JIRA)
noreply at atlassian.com
Tue Jul 7 07:29:12 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sandeep Vaid updated HHH-3938:
------------------------------
Attachment: EntityJoinWalker.java
This is a patch for this issue...
While fetching one-to-one association, filters are not applied.
I have modified the hibernate code to resolve this issue. With these changes, if filters a are enabled for one-to-one associations,
they will be applied (appear in sql) else not.
Changes Done:
A) In EntityJoinWalker.java >> constructor:line 40
Current Code:
StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
//include the discriminator and class-level where, but not filters
.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
Changed Code:
StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize );
//include the discriminator and class-level where, but not filters
String filter= persister.filterFragment( getAlias(), enabledFilters);
whereCondition.insert( 0, StringHelper.moveAndToBeginning(filter) );
> One-To-One Filter Applied, Non-Lazy Fetch Problem
> -------------------------------------------------
>
> Key: HHH-3938
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3938
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.3.1
> Reporter: Sandeep Vaid
> Priority: Critical
> Attachments: EntityJoinWalker.java
>
>
> Suppose i have one-to-one association between Product and ProductBasic. and we have applied filter on ProductBasic Class.
> I have applied this filter as in Java side we have one-to-one relationship between Product and ProductBasic BUT at database side
> we have one-to-many relationship between PRODUCT and PRODUCTBASIC. and we apply a condition (STARTTIME < CURRETTIME < ENDTIME)
> while fetching PRODUCTBASIC, and this will always give me one record out of many.
> So i have put this condition as filter in ProductBasic class.
> In current hibernate, one-to-one associations are always non-lazily fetched. Moreover it doesn't apply filter conditions.
> I understand that it can;t apply filter condition as some filter parameter must be provided at runtime and
> user may not provide them (as he is not asking for ProductBasic)... Also in this case, proper proxy can't be created as
> until we apply the filter criteria, we won't get one ProductBasic row (among many)..
> I think hibernate code should be changed so that if a filter is declared on the associated class (ProductBasic in our case),
> hibernate should return null for ProductBasic.
--
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