23
23
*/
24
24
package org .hibernate .bytecode .enhance .spi ;
25
25
26
+ import javassist .CtClass ;
26
27
import javassist .CtField ;
27
28
28
29
/**
30
+ * todo : not sure its a great idea to expose Javassist classes this way.
31
+ * maybe wrap them in our own contracts?
32
+ *
29
33
* @author Steve Ebersole
30
34
*/
31
35
public interface EnhancementContext {
32
36
/**
33
- * Does the given class name represent a entity class?
37
+ * Obtain access to the ClassLoader that can be used to load Class references. In JPA SPI terms, this
38
+ * should be a "temporary class loader" as defined by
39
+ * {@link javax.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader()}
40
+ */
41
+ public ClassLoader getLoadingClassLoader ();
42
+
43
+ /**
44
+ * Does the given class descriptor represent a entity class?
34
45
*
35
- * @param className The name of the class to check.
46
+ * @param classDescriptor The descriptor of the class to check.
36
47
*
37
48
* @return {@code true} if the class is an entity; {@code false} otherwise.
38
49
*/
39
- public boolean isEntityClass (String className );
50
+ public boolean isEntityClass (CtClass classDescriptor );
40
51
41
52
/**
42
53
* Does the given class name represent an embeddable/component class?
43
54
*
44
- * @param className The name of the class to check.
55
+ * @param classDescriptor The descriptor of the class to check.
45
56
*
46
57
* @return {@code true} if the class is an embeddable/component; {@code false} otherwise.
47
58
*/
48
- public boolean isCompositeClass (String className );
59
+ public boolean isCompositeClass (CtClass classDescriptor );
60
+
61
+ /**
62
+ * Should we in-line dirty checking for persistent attributes for this class?
63
+ *
64
+ * @param classDescriptor The descriptor of the class to check.
65
+ *
66
+ * @return {@code true} indicates that dirty checking should be in-lined within the entity; {@code false}
67
+ * indicates it should not. In-lined is more easily serializable and probably more performant.
68
+ */
69
+ public boolean doDirtyCheckingInline (CtClass classDescriptor );
70
+
71
+ public boolean hasLazyLoadableAttributes (CtClass classDescriptor );
72
+
73
+ // todo : may be better to invert these 2 such that the context is asked for an ordered list of persistent fields for an entity/composite
49
74
50
75
/**
51
76
* Does the field represent persistent state? Persistent fields will be "enhanced".
52
77
* <p/>
53
- * todo : not sure its a great idea to expose Javassist classes this way.
54
78
// may be better to perform basic checks in the caller (non-static, etc) and call out with just the
55
79
// Class name and field name...
56
80
@@ -59,4 +83,16 @@ public interface EnhancementContext {
59
83
* @return {@code true} if the field is ; {@code false} otherwise.
60
84
*/
61
85
public boolean isPersistentField (CtField ctField );
86
+
87
+ /**
88
+ * For fields which are persistent (according to {@link #isPersistentField}), determine the corresponding ordering
89
+ * maintained within the Hibernate metamodel.
90
+
91
+ * @param persistentFields The persistent field references.
92
+ *
93
+ * @return The ordered references.
94
+ */
95
+ public CtField [] order (CtField [] persistentFields );
96
+
97
+ public boolean isLazyLoadable (CtField field );
62
98
}
0 commit comments