Disable error in migration when field is not found

This error was useful when developing the system. Now however, it throws whenever a field is removed and the removal is not dealt with in a migrator. That we do not want.
This commit is contained in:
Magnus Ulf 2018-12-20 03:16:21 +01:00
parent b02bb196fd
commit 81519542e8

View File

@ -101,7 +101,7 @@ public class MigratorUtil
} }
// GET // GET
public static int getTargetVersion(Class<?> entityClass) public static int getTargetVersion(Class<?> entityClass)
{ {
if (!targetVersions.containsKey(entityClass)) if (!targetVersions.containsKey(entityClass))
{ {
@ -347,16 +347,19 @@ public class MigratorUtil
Class<?> superClass = ReflectionUtil.getSuperclassDeclaringField(entityClass, true, name); Class<?> superClass = ReflectionUtil.getSuperclassDeclaringField(entityClass, true, name);
// Try find field if it has a different serialisation name // Try find field if it has a different serialisation name
if (superClass == null) if (superClass == null) {
{
Field field = tryFindField(entityClass, name); Field field = tryFindField(entityClass, name);
if (field != null) if (field != null) {
{
name = field.getName(); name = field.getName();
superClass = entityClass; superClass = entityClass;
} }
} }
if (superClass == null) throw new RuntimeException(type.getTypeName() + " : " + name); if (superClass == null)
{
// Probably the field doesn't exist anymore, so this error is disabled.
//throw new RuntimeException(type.getTypeName() + " : " + name);
continue;
}
Type elementType = ReflectionUtil.getField(superClass, name).getGenericType(); Type elementType = ReflectionUtil.getField(superClass, name).getGenericType();
try try
{ {