public class QueryConfigurationClassTransformer extends Object implements BroadleafClassTransformer
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.Modifier and Type | Field and Description |
---|---|
protected List<String> |
managedClassNames |
protected List<javax.persistence.NamedQuery> |
namedQueries |
protected List<javax.persistence.NamedNativeQuery> |
nativeQueries |
Constructor and Description |
---|
QueryConfigurationClassTransformer(List<javax.persistence.NamedQuery> namedQueries,
List<javax.persistence.NamedNativeQuery> nativeQueries,
List<String> managedClassNames) |
Modifier and Type | Method and Description |
---|---|
void |
compileJPAProperties(Properties props,
Object key) |
protected void |
prepareNamedQueries(javassist.bytecode.ConstPool constantPool,
javassist.ClassPool pool,
javassist.bytecode.annotation.ArrayMemberValue queryArray)
Prepare the
NamedQueries declaration |
protected void |
prepareNativeQueries(javassist.bytecode.ConstPool constantPool,
javassist.ClassPool pool,
javassist.bytecode.annotation.ArrayMemberValue queryArray)
Prepare the
NamedNativeQueries declaration |
protected void |
prepareQueryHints(javassist.bytecode.ConstPool constantPool,
List<javassist.bytecode.annotation.AnnotationMemberValue> queryHints,
javax.persistence.QueryHint hint)
Prepare any
QueryHint declarations |
protected void |
processClassLevelAnnotations(javassist.bytecode.ConstPool constantPool,
javassist.ClassPool pool,
Object object)
Look for any existing
NamedQueries or NamedNativeQueries and embellish those declarations, if applicable. |
byte[] |
transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer) |
protected List<javax.persistence.NamedQuery> namedQueries
protected List<javax.persistence.NamedNativeQuery> nativeQueries
public void compileJPAProperties(Properties props, Object key) throws Exception
compileJPAProperties
in interface BroadleafClassTransformer
Exception
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
transform
in interface javax.persistence.spi.ClassTransformer
IllegalClassFormatException
protected void processClassLevelAnnotations(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, Object object) throws javassist.NotFoundException
NamedQueries
or NamedNativeQueries
and embellish those declarations, if applicable.
Otherwise, create new declarations of these annotations as needed.constantPool
- pool
- object
- javassist.NotFoundException
protected void prepareNativeQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) throws javassist.NotFoundException
NamedNativeQueries
declarationconstantPool
- pool
- queryArray
- javassist.NotFoundException
protected void prepareNamedQueries(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, javassist.bytecode.annotation.ArrayMemberValue queryArray) throws javassist.NotFoundException
NamedQueries
declarationconstantPool
- pool
- queryArray
- javassist.NotFoundException
protected void prepareQueryHints(javassist.bytecode.ConstPool constantPool, List<javassist.bytecode.annotation.AnnotationMemberValue> queryHints, javax.persistence.QueryHint hint)
QueryHint
declarationsconstantPool
- queryHints
- hint
- Copyright © 2022. All rights reserved.