[FIX] some annotation throws
This commit is contained in:
parent
38503fac8e
commit
f05527ce01
@ -258,15 +258,11 @@ public class AnnotationTools {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFieldName(final Field element) throws DataAccessException {
|
public static String getFieldName(final Field element) {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class);
|
||||||
if (annotation.length == 0) {
|
if (annotation.length == 0) {
|
||||||
return element.getName();
|
return element.getName();
|
||||||
}
|
}
|
||||||
if (annotation.length > 1) {
|
|
||||||
throw new DataAccessException(
|
|
||||||
"Must not have more than 1 element @Column on " + element.getClass().getCanonicalName());
|
|
||||||
}
|
|
||||||
final String name = ((Column) annotation[0]).name();
|
final String name = ((Column) annotation[0]).name();
|
||||||
if (name.isBlank()) {
|
if (name.isBlank()) {
|
||||||
return element.getName();
|
return element.getName();
|
||||||
|
@ -27,7 +27,7 @@ import jakarta.persistence.GenerationType;
|
|||||||
public class DataFactory {
|
public class DataFactory {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(DataFactory.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(DataFactory.class);
|
||||||
|
|
||||||
public static String convertTypeInSQL(final Class<?> type, final String fieldName) throws Exception {
|
public static String convertTypeInSQL(final Class<?> type, final String fieldName) throws DataAccessException {
|
||||||
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||||
if (type == UUID.class) {
|
if (type == UUID.class) {
|
||||||
return "binary(16)";
|
return "binary(16)";
|
||||||
|
@ -23,6 +23,7 @@ import org.kar.archidata.dataAccess.addOn.model.TableCoversLongUUID;
|
|||||||
import org.kar.archidata.dataAccess.addOn.model.TableCoversUUIDLong;
|
import org.kar.archidata.dataAccess.addOn.model.TableCoversUUIDLong;
|
||||||
import org.kar.archidata.dataAccess.addOn.model.TableCoversUUIDUUID;
|
import org.kar.archidata.dataAccess.addOn.model.TableCoversUUIDUUID;
|
||||||
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
||||||
|
import org.kar.archidata.exception.DataAccessException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class AddOnDataJson implements DataAccessAddOn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSQLFieldType(final Field elem) throws Exception {
|
public String getSQLFieldType(final Field elem) throws DataAccessException {
|
||||||
final String fieldName = AnnotationTools.getFieldName(elem);
|
final String fieldName = AnnotationTools.getFieldName(elem);
|
||||||
return DataFactory.convertTypeInSQL(String.class, fieldName);
|
return DataFactory.convertTypeInSQL(String.class, fieldName);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.kar.archidata.dataAccess.addOn.model;
|
package org.kar.archidata.dataAccess.addOn.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class TableCoversLongUUID {
|
|||||||
|
|
||||||
public TableCoversLongUUID(final Long id, final List<UUID> covers) {
|
public TableCoversLongUUID(final Long id, final List<UUID> covers) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.covers = covers;
|
this.covers = new ArrayList<>(covers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.kar.archidata.dataAccess.addOn.model;
|
package org.kar.archidata.dataAccess.addOn.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class TableCoversUUIDLong {
|
|||||||
|
|
||||||
public TableCoversUUIDLong(final UUID uuid, final List<Long> covers) {
|
public TableCoversUUIDLong(final UUID uuid, final List<Long> covers) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.covers = covers;
|
this.covers = new ArrayList<>(covers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user