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
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 Summary
FieldsFields inherited from class org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
alreadyLoadedClasses, preLoadClassNamePatterns -
Constructor Summary
ConstructorsConstructorDescriptionAlterTableNameClassTransformer(String tableName) AlterTableNameClassTransformer(String tableName, String targetedClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidalterTableAnnotation(javassist.bytecode.ClassFile classFile, String tableName, javassist.bytecode.ConstPool constantPool) Build class-level annotations from a template classvoidcompileJPAProperties(Properties props, Object key) voidsetTableName(String tableName) voidsetTargetedClass(String targetedClass) byte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) Methods inherited from class org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
afterPropertiesSet, setPreLoadClassNamePatterns
-
Field Details
-
tableName
-
targetedClass
-
-
Constructor Details
-
AlterTableNameClassTransformer
public AlterTableNameClassTransformer() -
AlterTableNameClassTransformer
-
AlterTableNameClassTransformer
-
-
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
-
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
-
setTableName
-
getTargetedClass
-
setTargetedClass
-