where can I find the code of org.springframework.orm.hibernate.support.Dependen cyInjectionInterceptorFactoryBean ?
Printable View
where can I find the code of org.springframework.orm.hibernate.support.Dependen cyInjectionInterceptorFactoryBean ?
In the sandbox directory in CVS.
I looked there but could not find it. Could someone give the exact location (or maybe a link)?. Thanks in advance for your help.
I found it! I was lokking in the wrong directory. Thnaks for your help.
Everything appears to be being wired up correctly for me using the three new classes from the sandbox with 1.1.1, except that my Hibernate persisted object does not get its setApplicationContext method called after being rehydrated (all the other properties are correctly wired). It implements ApplicationContextAware, but is there something additional that I need to do here?Quote:
Originally Posted by Rod Johnson
Thanks for any help.
It won't call setApplicationContext() with the autowiring approach. Autowiring does not register the object with the application context as a prototype, it merely does Dependency Injection based on resolving properties. This is consistent with the BeanFactory semantics on autowiring existing objects with dependencies from a factory.Quote:
Everything appears to be being wired up correctly for me using the three new classes from the sandbox with 1.1.1, except that my Hibernate persisted object does not get its setApplicationContext method called after being rehydrated (all the other properties are correctly wired).
If you want the ApplicationContextAware and other lifecycle interfaces to be invoked, you should use full factory management of your beans by defining them as prototypes.
Guess I should update the Javadoc to indicate this.
Ah, that makes sense now. After changing autowire to 0 and defining the prototypes in managedClassNamesToPrototypeNames, it works great.Quote:
Originally Posted by Rod Johnson
Thanks...
I've updated the Javadoc. Thanks for bringing this to my attention.
There is a slight inconsistency with how Hibernate might wire a bean's ID and how this new interceptor is doing it.
The interceptor will use BeanWrapper.setPropertyValue to set the ID. This will not work if the bean has only a getter for the ID (and only field access for the ID). If no setter exists, then a NotWritablePropertyException is thrown.
Hibernate, on the other hand, is able to use field access to set properties of a bean.
I wonder if the interceptor should first try setPropertyValue, and if it fails, to try setting the field directly? We removed our setId() method to make it more clear users aren't able to set this. We'll set it to private for now, but if we're able to set the ID via its field, that would be even better.
Any reason not to?
Actually, turns out I have to create a public setId() to get it to work with setPropertyValue.
I'd like to be able to work with private setters, or even better yet, just accessing the field. If this is a good idea, I'll post the patch.