IDEMPIERE-5631 - ModelEventHandler findTableName by Model annotation (#1739)

This commit is contained in:
matheus-marcelinux 2023-03-18 01:52:23 -03:00 committed by GitHub
parent e479eb5cfb
commit b11b7bcf95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -27,6 +27,7 @@ package org.adempiere.base.event.annotations;
import java.lang.reflect.Field;
import java.util.function.BiFunction;
import org.adempiere.base.Model;
import org.adempiere.base.event.EventHelper;
import org.adempiere.base.event.EventManager;
import org.compiere.model.PO;
@ -58,8 +59,13 @@ public final class ModelEventHandler<T extends PO> extends BaseEventHandler {
private void findTableName() {
try {
Field field = modelClassType.getField("Table_Name");
this.tableName = (String) field.get(null);
Model model = modelClassType.getSuperclass().getAnnotation(Model.class);
if(model != null)
this.tableName = model.table();
else {
Field field = modelClassType.getField("Table_Name");
this.tableName = (String) field.get(null);
}
setEventPropertyFilter(EventManager.TABLE_NAME_PROPERTY, tableName);
} catch (Exception e) {
if (e instanceof RuntimeException)