Class QueryConfigurationClassTransformer
java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.QueryConfigurationClassTransformer
- All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer,BroadleafClassTransformer
Detects any externally registered
NamedQueries or NamedNativeQueries and adds them to the first detected
entity implementation class for the target persistence unit. This is a JPA/Hibernate requirement and this approach
allows us to continue to be compatible with that, while still allowing client implementations to adopt this approach,
or continue to use the several standard approaches - including entity annotation, xml or runtime query creation.
See QueryConfiguration for more information on configuring named queries externally.- Author:
- Jeff Fischer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQueryConfigurationClassTransformer(List<jakarta.persistence.NamedQuery> namedQueries, List<jakarta.persistence.NamedNativeQuery> nativeQueries, List<String> managedClassNames) -
Method Summary
Modifier and TypeMethodDescriptionvoidcompileJPAProperties(Properties props, Object key) protected voidprepareNamedQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) Prepare theNamedQueriesdeclarationprotected voidprepareNativeQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) Prepare theNamedNativeQueriesdeclarationprotected voidprepareQueryHints(javassist.bytecode.ConstPool constantPool, List<javassist.bytecode.annotation.AnnotationMemberValue> queryHints, jakarta.persistence.QueryHint hint) Prepare anyQueryHintdeclarationsprotected voidprocessClassLevelAnnotations(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, Object object) Look for any existingNamedQueriesorNamedNativeQueriesand embellish those declarations, if applicable.byte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
-
Field Details
-
namedQueries
-
nativeQueries
-
managedClassNames
-
-
Constructor Details
-
QueryConfigurationClassTransformer
-
-
Method Details
-
compileJPAProperties
- Specified by:
compileJPAPropertiesin interfaceBroadleafClassTransformer- Throws:
Exception
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException - Specified by:
transformin interfacejakarta.persistence.spi.ClassTransformer- Throws:
IllegalClassFormatException
-
processClassLevelAnnotations
protected void processClassLevelAnnotations(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, Object object) throws javassist.NotFoundException Look for any existingNamedQueriesorNamedNativeQueriesand embellish those declarations, if applicable. Otherwise, create new declarations of these annotations as needed.- Parameters:
constantPool-pool-object-- Throws:
javassist.NotFoundException
-
prepareNativeQueries
protected void prepareNativeQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) throws javassist.NotFoundException Prepare theNamedNativeQueriesdeclaration- Parameters:
constantPool-pool-queryArray-- Throws:
javassist.NotFoundException
-
prepareNamedQueries
protected void prepareNamedQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) throws javassist.NotFoundException Prepare theNamedQueriesdeclaration- Parameters:
constantPool-pool-queryArray-- Throws:
javassist.NotFoundException
-
prepareQueryHints
protected void prepareQueryHints(javassist.bytecode.ConstPool constantPool, List<javassist.bytecode.annotation.AnnotationMemberValue> queryHints, jakarta.persistence.QueryHint hint) Prepare anyQueryHintdeclarations- Parameters:
constantPool-queryHints-hint-
-