KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > proxy > HibernateProxyHelper


1 //$Id: HibernateProxyHelper.java,v 1.7 2004/08/29 07:31:02 oneovthafew Exp $
2
package org.hibernate.proxy;
3
4
5 /**
6  * Utility methods for working with proxies. (this class is being phased out)
7  * @author Gavin King
8  */

9 public final class HibernateProxyHelper {
10
11     /**
12      * Get the class of an instance or the underlying class
13      * of a proxy (without initializing the proxy!). It is
14      * almost always better to use the entity name!
15      */

16     public static Class JavaDoc getClassWithoutInitializingProxy(Object JavaDoc object) {
17         if (object instanceof HibernateProxy) {
18             HibernateProxy proxy = (HibernateProxy) object;
19             LazyInitializer li = proxy.getHibernateLazyInitializer();
20             return li.getPersistentClass();
21         }
22         else {
23             return object.getClass();
24         }
25     }
26
27     private HibernateProxyHelper() {
28         //cant instantiate
29
}
30
31 }
32
33
34
35
36
37
38
Popular Tags