如何从代理类中检索代理类? [英] How do I retrieve the proxied class from the proxy class?

查看:112
本文介绍了如何从代理类中检索代理类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Hibernate与代理一起使用,并且我得到属于类的对象,如 test.DBUser $$ EnhancerByCGLIB $$ 40e99a2d

I'm using Hibernate with proxies, and I get objects belonging to classes such as test.DBUser$$EnhancerByCGLIB$$40e99a2d.

是否有Hibernate方法从代理的中检索基类(本例中为 test.DBUser ) ?我知道 Hibernate.getClass(),但它需要一个 Object ,而我正在寻找一种方法作为输入 Class

Is there a Hibernate method to retrieve the base class (test.DBUser in this case) from the proxied class? I know about Hibernate.getClass(), but it takes an Object, while I'm looking for a method which takes as input a Class.

推荐答案

我发现,它是比我想象的要容易:只需在代理类上调用 getSuperclass()即可获得未加载的原始类。我不确定这是多么普遍,但它似乎有效。

I found out, it is easier than I thought: just call getSuperclass() on the proxied class to obtain the unproxied, original class. I'm not sure how general this is, but it appears to work.

这篇关于如何从代理类中检索代理类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆