DataSource ds = SessionFactoryUtils.getDataSource(sf);
Unforunately, because my SessionFactory is a proxy object, this code was returning null... still not sure why. I knew it worked with the 'un-proxied' SessionFactory, so needed to get access to it. If you are ever in this bind, here is a snippit that will work:
publicT getTargetObject(Object proxy, Class targetClass) throws Exception {
if (AopUtils.isJdkDynamicProxy(proxy) && proxy instanceof Advised) {
return (T) ((Advised)proxy).getTargetSource().getTarget();
} else {
return (T) proxy;
}
}
Hope this helps! Any comments, please post'em.
Cheers,
Yeuker
No comments:
Post a Comment