Hibernate version: 2.1.6
Is it really necessary that AbstractEntityPersister in its constructor enforce persisted classes provide a default constructor? I'm in a scenario where I'm persisting some classes that don't/can't have a default constructor, but I'm using an Interceptor instance that uses the instantiate method to create the instances for these classes. It works great, but I can't use the standard EntityPersister, since it requires any non-interface/abstract class to provide a default constructor.
Based on my reading of various Hibernate documents, the "default constructor" requirement seems like a fundamental tenet of Hibernate use. But this seems unnecessary, given the availability of Interceptor.instantiate and that AbstractEntityPersister adequately handles interfaces and abstract classes, which clearly provide no default constructors.
My workaround for this was to create my own ClassPersister implementation that looks eerily similar to EntityPersister + AbstractEntityPersister. Its only difference is that it doesn't throw an exception if the persisted class doesn't provide a default constructor; it just sets the constructor field to null.
I'm not terribly fond of this solution, even though it works great, since I'm basically duplicating the whole of EntityPersister. There doesn't seem to be an easy way around this, since the contstructor requirement is in AbstractEntityPersister's constructor; there's no method to overload or setting to change. Thus, I think it could constitute a bug, but I thought I'd discuss it in the forum first to make sure there's no fundamental Hibernate issue that I'm violating or not understanding completely.
Any comments appreciated.
-Scott
|