Class QueryConfigurationClassTransformer

java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.QueryConfigurationClassTransformer
All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer, BroadleafClassTransformer

public class QueryConfigurationClassTransformer extends Object implements 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 Details

    • namedQueries

      protected List<jakarta.persistence.NamedQuery> namedQueries
    • nativeQueries

      protected List<jakarta.persistence.NamedNativeQuery> nativeQueries
    • managedClassNames

      protected List<String> managedClassNames
  • Constructor Details

    • QueryConfigurationClassTransformer

      public QueryConfigurationClassTransformer(List<jakarta.persistence.NamedQuery> namedQueries, List<jakarta.persistence.NamedNativeQuery> nativeQueries, List<String> managedClassNames)
  • Method Details

    • compileJPAProperties

      public void compileJPAProperties(Properties props, Object key) throws Exception
      Specified by:
      compileJPAProperties in interface BroadleafClassTransformer
      Throws:
      Exception
    • transform

      public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
      Specified by:
      transform in interface jakarta.persistence.spi.ClassTransformer
      Throws:
      IllegalClassFormatException
    • processClassLevelAnnotations

      protected void processClassLevelAnnotations(javassist.bytecode.ConstPool constantPool, javassist.ClassPool pool, Object object) throws javassist.NotFoundException
      Look for any existing NamedQueries or NamedNativeQueries 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 the NamedNativeQueries 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 the NamedQueries 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 any QueryHint declarations
      Parameters:
      constantPool -
      queryHints -
      hint -