Skip to content

Commit 8c96a4a

Browse files
committed
HHH-7667 - Investigate expanding bytecode enhancement support
(cherry picked from commit 30b3bd1)
1 parent 60836cd commit 8c96a4a

File tree

13 files changed

+1373
-339
lines changed

13 files changed

+1373
-339
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/EnhancementContext.java

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,58 @@
2323
*/
2424
package org.hibernate.bytecode.enhance.spi;
2525

26+
import javassist.CtClass;
2627
import javassist.CtField;
2728

2829
/**
30+
* todo : not sure its a great idea to expose Javassist classes this way.
31+
* maybe wrap them in our own contracts?
32+
*
2933
* @author Steve Ebersole
3034
*/
3135
public interface EnhancementContext {
3236
/**
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?
3445
*
35-
* @param className The name of the class to check.
46+
* @param classDescriptor The descriptor of the class to check.
3647
*
3748
* @return {@code true} if the class is an entity; {@code false} otherwise.
3849
*/
39-
public boolean isEntityClass(String className);
50+
public boolean isEntityClass(CtClass classDescriptor);
4051

4152
/**
4253
* Does the given class name represent an embeddable/component class?
4354
*
44-
* @param className The name of the class to check.
55+
* @param classDescriptor The descriptor of the class to check.
4556
*
4657
* @return {@code true} if the class is an embeddable/component; {@code false} otherwise.
4758
*/
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
4974

5075
/**
5176
* Does the field represent persistent state? Persistent fields will be "enhanced".
5277
* <p/>
53-
* todo : not sure its a great idea to expose Javassist classes this way.
5478
// may be better to perform basic checks in the caller (non-static, etc) and call out with just the
5579
// Class name and field name...
5680
@@ -59,4 +83,16 @@ public interface EnhancementContext {
5983
* @return {@code true} if the field is ; {@code false} otherwise.
6084
*/
6185
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);
6298
}

0 commit comments

Comments
 (0)