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 TypeMethodDescriptionvoid
compileJPAProperties
(Properties props, Object key) protected void
prepareNamedQueries
(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) Prepare theNamedQueries
declarationprotected void
prepareNativeQueries
(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) Prepare theNamedNativeQueries
declarationprotected void
prepareQueryHints
(javassist.bytecode.ConstPool constantPool, List<javassist.bytecode.annotation.AnnotationMemberValue> queryHints, jakarta.persistence.QueryHint hint) Prepare anyQueryHint
declarationsprotected void
processClassLevelAnnotations
(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, Object object) Look for any existingNamedQueries
orNamedNativeQueries
and 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:
compileJPAProperties
in interfaceBroadleafClassTransformer
- Throws:
Exception
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException - Specified by:
transform
in 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 existingNamedQueries
orNamedNativeQueries
and 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 theNamedNativeQueries
declaration- 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 theNamedQueries
declaration- 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 anyQueryHint
declarations- Parameters:
constantPool
-queryHints
-hint
-
-