From 058fb2e64016225a6a79226a0450861ab5b96acb Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 31 Dec 2023 09:27:43 +0100 Subject: [PATCH] [DEV] fix size error in string --- src/org/kar/archidata/annotation/AnnotationTools.java | 4 ++-- src/org/kar/archidata/dataAccess/DataFactory.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/org/kar/archidata/annotation/AnnotationTools.java b/src/org/kar/archidata/annotation/AnnotationTools.java index 80a4837..9de6323 100644 --- a/src/org/kar/archidata/annotation/AnnotationTools.java +++ b/src/org/kar/archidata/annotation/AnnotationTools.java @@ -129,7 +129,7 @@ public class AnnotationTools { return ((Min) annotation[0]).value(); } - public static Integer getLimitSize(final Field element) throws Exception { + public static int getLimitSize(final Field element) throws Exception { final Annotation[] annotation = element.getDeclaredAnnotationsByType(Column.class); if (annotation.length == 0) { return 255; @@ -138,7 +138,7 @@ public class AnnotationTools { throw new Exception("Must not have more than 1 element @Column on " + element.getClass().getCanonicalName()); } final int length = ((Column) annotation[0]).length(); - return length <= 0 ? null : length; + return length <= 0 ? 0 : length; } public static Size getConstraintsSize(final Field element) throws Exception { diff --git a/src/org/kar/archidata/dataAccess/DataFactory.java b/src/org/kar/archidata/dataAccess/DataFactory.java index 9073804..1baa6b8 100644 --- a/src/org/kar/archidata/dataAccess/DataFactory.java +++ b/src/org/kar/archidata/dataAccess/DataFactory.java @@ -131,7 +131,7 @@ public class DataFactory { public static void createTablesSpecificType(final String tableName, final Field elem, final StringBuilder mainTableBuilder, final List preOtherTables, final List postOtherTables, final boolean createIfNotExist, final boolean createDrop, final int fieldId, final Class classModel) throws Exception { final String name = AnnotationTools.getFieldName(elem); - final Integer limitSize = AnnotationTools.getLimitSize(elem); + final int limitSize = AnnotationTools.getLimitSize(elem); final boolean notNull = AnnotationTools.getColumnNotNull(elem); final boolean primaryKey = AnnotationTools.isPrimaryKey(elem); @@ -152,7 +152,7 @@ public class DataFactory { String typeValue = null; typeValue = convertTypeInSQL(classModel, name); if ("text".equals(typeValue) && !"sqlite".equals(ConfigBaseVariable.getDBType())) { - if (limitSize != null) { + if (limitSize > 0) { mainTableBuilder.append("varchar("); mainTableBuilder.append(limitSize); mainTableBuilder.append(")");