From: Gavin K. <ga...@ap...> - 2002-11-06 14:05:05
|
I think its better to do this kind of thing by subclassing EntityPersister and overriding instantiate(). However, that will not work properly in the current implentation (for example getPersister( object.getClass() ) would fail). Would you please investigate what kind of changes would be required to make this approach work? ----- Original Message ----- From: "Chris Nokleberg" <ch...@si...> To: <hib...@li...> Sent: Wednesday, November 06, 2002 10:27 AM Subject: [Hibernate] Hooking into Hibernate classloader > I'd like to dynamically wrap my persistent classes using CGLIB or JDK1.3 > proxies to provide things like getters for metadata which aren't in the > compiled class file. I've done some searching and it appears that all of the > persistent classes are loaded by Hibernate using > > cirrus.hibernate.helpers.ReflectHelper.classForName(String) > > which is implemented as: > > public static Class classForName(String name) throws ClassNotFoundException { > try { > return Thread.currentThread().getContextClassLoader().loadClass(name); > } catch (Exception e) { > return Class.forName(name); > } > } > > One option would be to try to set the current context class loader before > Hibernate starts loading classes. But that is error-prone, I think. Another > way would be to add a method to set the classloader to use. But really I'd > just prefer a simple callback interface: > > public interface HibernateClassLoader { > public Class loadClass(String name) throws ClassNotFoundException; > } > > I guess the loader would be configurable per-datastore? > If there's a better way, let me know. > > Thanks, > Chris > > > ------------------------------------------------------- > This sf.net email is sponsored by: See the NEW Palm > Tungsten T handheld. Power & Color in a compact size! > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |