public class AlterTableNameClassTransformer extends AbstractClassTransformer implements BroadleafClassTransformer
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 Product 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.
| Modifier and Type | Field and Description |
|---|---|
protected String |
tableName |
protected String |
targetedClass |
alreadyLoadedClasses, preLoadClassNamePatterns| Constructor and Description |
|---|
AlterTableNameClassTransformer() |
AlterTableNameClassTransformer(String tableName) |
AlterTableNameClassTransformer(String tableName,
String targetedClass) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
alterTableAnnotation(javassist.bytecode.ClassFile classFile,
String tableName,
javassist.bytecode.ConstPool constantPool)
Build class-level annotations from a template class
|
void |
compileJPAProperties(Properties props,
Object key) |
String |
getTableName() |
String |
getTargetedClass() |
void |
setTableName(String tableName) |
void |
setTargetedClass(String targetedClass) |
byte[] |
transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer) |
afterPropertiesSet, setPreLoadClassNamePatternspublic AlterTableNameClassTransformer()
public AlterTableNameClassTransformer(String tableName)
public void compileJPAProperties(Properties props, Object key) throws Exception
compileJPAProperties in interface BroadleafClassTransformerExceptionpublic byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
transform in interface javax.persistence.spi.ClassTransformerIllegalClassFormatExceptionprotected void alterTableAnnotation(javassist.bytecode.ClassFile classFile,
String tableName,
javassist.bytecode.ConstPool constantPool)
throws javassist.NotFoundException
classFile - tableName - constantPool - javassist.NotFoundExceptionpublic String getTableName()
public void setTableName(String tableName)
public String getTargetedClass()
public void setTargetedClass(String targetedClass)
Copyright © 2021. All rights reserved.