On 8 juil. 2011, at 11:44, Robin Sander wrote:

> 
> Isn't that totally independent from a method beeing final or not?
> If I have a method:
> 
> public int getSum() {
>  return field1 + field2;
> }
> 
> Then this would trigger the initialization of the entity (in 
> JavassistLazyInitializer I assume)
> and 
> 
> public final int getSum() {
>  return field1 + field2;
> }
> 
> would not? (if field1 and field2 are persistent fields and field-based access 
> is used)

correct. we can't intercept a final method and thus can't initialize when you 
call getSum()

> 
> Only yesterday I've stumpled upon a related issue in equals(): I've compared 
> a persistent field of two instances
> of the same entity and that _did not_ trigger the initialization of the other 
> instance proxy. So there I had to use
> "If (this.field.equals(other.getField())) { ..."  instead of If 
> (this.field.equals(other.field)) { ..."
> and no method of that entity was final.

Not the same but related. you are bypassing the proxy and thus don't initialize.


_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to