[hibernate-dev] Hibernate.getImplementation(Object)

Max Rydahl Andersen max.andersen at redhat.com
Wed May 23 19:24:38 EDT 2007


why are you ever in need of touching the field values directly ?

Accessing and potentially exposing the underlying object of a proxied  
entity should be strictly prohibted
since otherwise you easily end up with breaking ==

/max

> For Hibernate Search I came to a problem.
> When a user choose field access.
> When I access a previously uninitialized object, and even if I  
> initialize it (Hibernate.initialize()).
>
> The field access End up returning null all the time because of the way  
> lazy loading is done. I worked around that using some of the code from  
> Hibernate.initialize()
>
> 		if ( value instanceof HibernateProxy ) {
> 			value = ( ( HibernateProxy ) value ).getHibernateLazyInitializer()
> 					.getImplementation();
> 		}
>
> But it seems it really should be part of the Hibernate class contract.
>
> I could use
>
> 		Hibernate.initialize(value);
> 		value = session.get( Hibernate.getClass(value),  
> session.getIdentifier(value) );
>
> but at the present time, it's hard for me to access the session, and  
> conceptually speaking there is no real need for it.
>
> How about exposing this service in Hibernate class either
>
> 		value = Hibernate.initialize(value); //changing the return value
> or
> 		value = Hibernate.getImplementation(value);
>
> WDYT?
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev



-- 
--
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
max at hibernate.org
http://hibernate.org

JBoss a division of Red Hat
max.andersen at jboss.com




More information about the hibernate-dev mailing list