1 | public final class SerializableProxy implements Serializable {↵ | | 1 | public final class SerializableProxy implements Serializable {↵
|
|
2 | private String entityName;↵ | | 2 | private String entityName;↵
|
3 | private Class persistentClass;↵ | | 3 | private Class persistentClass;↵
|
4 | private Class[] interfaces;↵ | | 4 | private Class[] interfaces;↵
|
5 | private Serializable id;↵ | | 5 | private Serializable id;↵
|
6 | private Class getIdentifierMethodClass;↵ | | 6 | private Class getIdentifierMethodClass;↵
|
7 | private Class setIdentifierMethodClass;↵ | | 7 | private Class setIdentifierMethodClass;↵
|
8 | private String getIdentifierMethodName;↵ | | 8 | private String getIdentifierMethodName;↵
|
9 | private String setIdentifierMethodName;↵ | | 9 | private String setIdentifierMethodName;↵
|
10 | private Class[] setIdentifierMethodParams;↵ | | 10 | private Class[] setIdentifierMethodParams;↵
|
11 | private AbstractComponentType componentIdType;↵ | | 11 | private AbstractComponentType componentIdType;↵
|
|
12 | public SerializableProxy() {}↵ | | 12 | public SerializableProxy() {}↵
|
|
13 | public SerializableProxy(↵ | | 13 | public SerializableProxy(↵
|
14 | final String entityName,↵ | | 14 | final String entityName,↵
|
15 | final Class persistentClass,↵ | | 15 | final Class persistentClass,↵
|
16 | final Class[] interfaces,↵ | | 16 | final Class[] interfaces,↵
|
17 | final Serializable id,↵ | | 17 | final Serializable id,↵
|
18 | final Method getIdentifierMethod,↵ | | 18 | final Method getIdentifierMethod,↵
|
19 | final Method setIdentifierMethod,↵ | | 19 | final Method setIdentifierMethod,↵
|
20 | AbstractComponentType componentIdType↵ | | 20 | AbstractComponentType componentIdType↵
|
21 | ) {↵ | | 21 | ) {↵
|
22 | this.entityName = entityName;↵ | | 22 | this.entityName = entityName;↵
|
23 | this.persistentClass = persistentClass;↵ | | 23 | this.persistentClass = persistentClass;↵
|
24 | this.interfaces = interfaces;↵ | | 24 | this.interfaces = interfaces;↵
|
25 | this.id = id;↵ | | 25 | this.id = id;↵
|
26 | if (getIdentifierMethod!=null) {↵ | | 26 | if (getIdentifierMethod!=null) {↵
|
27 | getIdentifierMethodClass = getIdentifierMethod.getDeclaringClass();↵ | | 27 | getIdentifierMethodClass = getIdentifierMethod.getDeclaringClass();↵
|
28 | getIdentifierMethodName = getIdentifierMethod.getName();↵ | | 28 | getIdentifierMethodName = getIdentifierMethod.getName();↵
|
29 | }↵ | | 29 | }↵
|
30 | if (setIdentifierMethod!=null) {↵ | | 30 | if (setIdentifierMethod!=null) {↵
|
31 | setIdentifierMethodClass = setIdentifierMethod.getDeclaringClass();↵ | | 31 | setIdentifierMethodClass = setIdentifierMethod.getDeclaringClass();↵
|
32 | setIdentifierMethodName = setIdentifierMethod.getName();↵ | | 32 | setIdentifierMethodName = setIdentifierMethod.getName();↵
|
33 | setIdentifierMethodParams = setIdentifierMethod.getParameterTypes();↵ | | 33 | setIdentifierMethodParams = setIdentifierMethod.getParameterTypes();↵
|
34 | }↵ | | 34 | }↵
|
35 | this.componentIdType = componentIdType;↵ | | 35 | this.componentIdType = componentIdType;↵
|
36 | }↵ | | 36 | }↵
|
|
37 | private Object readResolve() {↵ | | 37 | private Object readResolve() {↵
|
38 | try {↵ | | 38 | try {↵
|
39 | return CGLIBLazyInitializer.getProxy(↵ | | 39 | return JavassistLazyInitializer.getProxy(↵
|
40 | entityName,↵ | | 40 | entityName,↵
|
41 | persistentClass,↵ | | 41 | persistentClass,↵
|
42 | interfaces,↵ | | 42 | interfaces,↵
|
43 | getIdentifierMethodName==null ?↵ | | 43 | getIdentifierMethodName==null ?↵
|
44 | null :↵ | | 44 | null :↵
|
45 | getIdentifierMethodClass.getDeclaredMethod(getIdentifierMethodName, null),↵ | | 45 | getIdentifierMethodClass.getDeclaredMethod(getIdentifierMethodName, null),↵
|
46 | setIdentifierMethodName==null ?↵ | | 46 | setIdentifierMethodName==null ?↵
|
47 | null :↵ | | 47 | null :↵
|
48 | setIdentifierMethodClass.getDeclaredMethod(setIdentifierMethodName, setIdentifierMethodParams),↵ | | 48 | setIdentifierMethodClass.getDeclaredMethod(setIdentifierMethodName, setIdentifierMethodParams),↵
|
49 | componentIdType,↵ | | 49 | componentIdType,↵
|
50 | id,↵ | | 50 | id,↵
|
51 | null↵ | | 51 | null↵
|
52 | );↵ | | 52 | );↵
|
53 | }↵ | | 53 | }↵
|
54 | catch (NoSuchMethodException nsme) {↵ | | 54 | catch (NoSuchMethodException nsme) {↵
|
55 | throw new HibernateException("could not create proxy for entity: " + entityName, nsme);↵ | | 55 | throw new HibernateException("could not create proxy for entity: " + entityName, nsme);↵
|
56 | | | 56 |
|