[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3917) @NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
Vlasov Igor (JIRA)
noreply at atlassian.com
Tue May 19 01:29:13 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33198#action_33198 ]
Vlasov Igor commented on HHH-3917:
----------------------------------
Then
method org.hibernate.event.def.DefaultLoadEventListener.load(...) results in rotected Object loadFromDatasource(
final LoadEvent event,
final EntityPersister persister,
final EntityKey keyToLoad,
final LoadEventListener.LoadType options) {
.....
In this method There is no condition in parameter "final LoadEventListener.LoadType options" (in my case INTERNAL_LOAD_NULLABLE)
> @NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
> -------------------------------------------------------------------------------------------------------------
>
> Key: HHH-3917
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3917
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.3.1
> Reporter: Vlasov Igor
>
> Hello
> I try to use @org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE) annotation to avoid of throwing an exception IN
> @JoinColumn(name = "UR_ID", referencedColumnName = "UR_ID")
> @ManyToOne(fetch = FetchType.LAZY)
> @org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE)
> @Basic(optional=true)
> private UserRole role;
> Then it results me to EAGER loading of this field.
> Throw days of debuging i have found that:
> 1. @org.hibernate.annotations.NotFound results in:
> isNullable()=true
> for org.hibernate.type.ManyToOneType
> 2. in org.hibernate.impl.SessionImpl and method internalLoad i can see:
> LoadEventListener.LoadType type = nullable ?
> LoadEventListener.INTERNAL_LOAD_NULLABLE :
> eager ? LoadEventListener.INTERNAL_LOAD_EAGER : LoadEventListener.INTERNAL_LOAD_LAZY;
> Threrefore we have LoadEventListener.INTERNAL_LOAD_NULLABLE type of loading my relation. !!!
> and in class org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE I can see setAllowProxyCreation(false) !!!!
> 3. in org.hibernate.event.def.DefaultLoadEventListener in line 218 there is a condition:
> if ( options.isAllowProxyCreation() ) {
> return createProxyIfNecessary( event, persister, keyToLoad, options, persistenceContext );
> } else {
> return load(event, persister, keyToLoad, options);
> }
> In my case LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() ==false !!
> and it results in LOADING of Object !!!
> Can we set LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() to true ?
> org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE = new LoadType("INTERNAL_LOAD_NULLABLE")
> .setAllowNulls(true)
> .setAllowProxyCreation(false)
> .setCheckDeleted(false)
> .setNakedEntityReturned(false);
--
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