Class AlterTableNameClassTransformer

java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
org.broadleafcommerce.common.extensibility.jpa.convert.AlterTableNameClassTransformer
All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer, BroadleafClassTransformer, org.springframework.beans.factory.InitializingBean

public class AlterTableNameClassTransformer extends AbstractClassTransformer implements BroadleafClassTransformer
This BroadleafClassTransformer changes the name of the Table for an entity before Hibernate sees it. This allows us to safely change/alter the names of Tables for entities on patch releases.

Example of changing the Table name of org.broadleafcommerce.core.catalog.domain.ProductImpl to "BLC_ALTER_PRODUCT"

In applicationContext.xml

```xml <constructor-arg name="tableName" value="BLC_ALTER_PRODUCT" /> <constructor-arg name="targetedClass" value="org.broadleafcommerce.core.catalog.domain.ProductImpl" /> ```

NOTE :* This will add a new table in the database and does *NOT* change the name of existing tables in a database.

Created by ReggieCole on 4/3/17.

  • Field Details

    • tableName

      protected String tableName
    • targetedClass

      protected String targetedClass
  • Constructor Details

    • AlterTableNameClassTransformer

      public AlterTableNameClassTransformer()
    • AlterTableNameClassTransformer

      public AlterTableNameClassTransformer(String tableName)
    • AlterTableNameClassTransformer

      public AlterTableNameClassTransformer(String tableName, String targetedClass)
  • 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
    • alterTableAnnotation

      protected void alterTableAnnotation(javassist.bytecode.ClassFile classFile, String tableName, javassist.bytecode.ConstPool constantPool) throws javassist.NotFoundException
      Build class-level annotations from a template class
      Parameters:
      classFile -
      tableName -
      constantPool -
      Throws:
      javassist.NotFoundException
    • getTableName

      public String getTableName()
    • setTableName

      public void setTableName(String tableName)
    • getTargetedClass

      public String getTargetedClass()
    • setTargetedClass

      public void setTargetedClass(String targetedClass)