From f61b163b99733c14ffd7530eb2f3d0dfbdd53960 Mon Sep 17 00:00:00 2001 From: Nikita Timofeev Date: Wed, 27 Sep 2017 13:05:25 +0300 Subject: [PATCH 1/2] Use boxed types for nullable primitive fields --- .../resources/templates/v4_1/singleclass.vm | 35 ++++++++++--- .../resources/templates/v4_1/superclass.vm | 34 +++++++++---- .../cayenne/access/OptimisticLockingIT.java | 50 +++++++++++-------- .../auto/_SimpleLockingTestEntity.java | 41 +++++++++++++++ .../primitive/auto/_PrimitivesTestEntity.java | 22 +++++--- .../src/test/resources/cayenne-locking.xml | 2 + .../src/test/resources/cayenne-primitive.xml | 2 + .../src/test/resources/locking.map.xml | 4 ++ .../src/test/resources/primitive.map.xml | 2 +- .../cayenne/modeler/CodeTemplateManager.java | 12 +++-- 10 files changed, 152 insertions(+), 52 deletions(-) diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm index d1888e0f5f..40d6ef0fd9 100644 --- a/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm +++ b/cayenne-cgen/src/main/resources/templates/v4_1/singleclass.vm @@ -101,7 +101,8 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} ## Create Fields ## ################### #foreach( $attr in ${object.DeclaredAttributes} ) -#set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)") +## don't use primitive type if attribute is nullable +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") protected $type $stringUtils.formatVariableName(${attr.Name}); #end @@ -114,10 +115,12 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} ######################################################### #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type})") ## ## setter +## #if ("true" != "${object.isReadOnly()}") - public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $name) { + public void set${stringUtils.capitalized($attr.Name)}($type $name) { beforePropertyWrite("${attr.Name}", this.$name, $name); this.$name = $name; } @@ -125,16 +128,26 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} #end ## ## getter +## #if ( $importUtils.isBoolean(${attr.Type}) ) public boolean is${stringUtils.capitalized($attr.Name)}() { #else - public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() { + public $type get${stringUtils.capitalized($attr.Name)}() { #end beforePropertyRead("${attr.Name}"); - return this.$stringUtils.formatVariableName(${attr.Name}); +#if ($importUtils.isPrimitive($type) && !$attr.isMandatory()) + if(this.$name == null) { +#if ($importUtils.isBoolean($type)) + return false; +#else + return 0; +#end + } +#end + return this.$name; } -#end +#end## of foreach declared attribute ## ## Create list add/remove/get methods #foreach( $rel in ${object.DeclaredRelationships} ) @@ -214,10 +227,16 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} switch (propName) { #foreach( $attr in ${object.DeclaredAttributes} ) -#set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") case "${attr.Name}": +#if ( $importUtils.isBoolean($type) ) + this.${name} = val == null ? false : ($type)val; +#elseif ($importUtils.isPrimitive($type)) + this.${name} = val == null ? 0 : ($type)val; +#else this.${name} = ($type)val; +#end break; #end #foreach( $rel in ${object.DeclaredRelationships} ) @@ -246,7 +265,7 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} super.writeState(out); #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") -#set ( $type = "$importUtils.formatJavaType(${attr.Type})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #if($importUtils.isPrimitive($type)) out.write${stringUtils.capitalized($type)}(this.$name); #else @@ -263,7 +282,7 @@ public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} super.readState(in); #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") -#set ( $type = "$importUtils.formatJavaType(${attr.Type})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #if($importUtils.isPrimitive($type)) this.$name = in.read${stringUtils.capitalized($type)}(); #else diff --git a/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm b/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm index 8f8bcfe71e..97c97161f4 100644 --- a/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm +++ b/cayenne-cgen/src/main/resources/templates/v4_1/superclass.vm @@ -109,7 +109,8 @@ public abstract class ${superClassName} extends ${baseClassName} { ## Create Fields ## ################### #foreach( $attr in ${object.DeclaredAttributes} ) -#set ( $type = "$importUtils.formatJavaType(${attr.Type})") +## don't use primitive type if attribute is nullable +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") protected $type $stringUtils.formatVariableName(${attr.Name}); #end @@ -122,10 +123,12 @@ public abstract class ${superClassName} extends ${baseClassName} { ######################################################### #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type})") ## ## setter +## #if ("true" != "${object.isReadOnly()}") - public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $name) { + public void set${stringUtils.capitalized($attr.Name)}($type $name) { beforePropertyWrite("${attr.Name}", this.$name, $name); this.$name = $name; } @@ -133,16 +136,26 @@ public abstract class ${superClassName} extends ${baseClassName} { #end ## ## getter +## #if ( $importUtils.isBoolean(${attr.Type}) ) public boolean is${stringUtils.capitalized($attr.Name)}() { #else - public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() { + public $type get${stringUtils.capitalized($attr.Name)}() { #end beforePropertyRead("${attr.Name}"); - return this.$stringUtils.formatVariableName(${attr.Name}); +#if ($importUtils.isPrimitive($type) && !$attr.isMandatory()) + if(this.$name == null) { +#if ($importUtils.isBoolean($type)) + return false; +#else + return 0; +#end + } +#end + return this.$name; } -#end +#end## of foreach declared attribute ## ## Create list add/remove/get methods #foreach( $rel in ${object.DeclaredRelationships} ) @@ -220,13 +233,12 @@ public abstract class ${superClassName} extends ${baseClassName} { switch (propName) { #foreach( $attr in ${object.DeclaredAttributes} ) -#set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)") -#set ( $realType = "$importUtils.formatJavaType(${attr.Type})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") case "${attr.Name}": -#if ( $importUtils.isBoolean($realType) ) +#if ( $importUtils.isBoolean($type) ) this.${name} = val == null ? false : ($type)val; -#elseif ($importUtils.isPrimitive($realType)) +#elseif ($importUtils.isPrimitive($type)) this.${name} = val == null ? 0 : ($type)val; #else this.${name} = ($type)val; @@ -259,7 +271,7 @@ public abstract class ${superClassName} extends ${baseClassName} { super.writeState(out); #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") -#set ( $type = "$importUtils.formatJavaType(${attr.Type})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #if($importUtils.isPrimitive($type)) out.write${stringUtils.capitalized($type)}(this.$name); #else @@ -276,7 +288,7 @@ public abstract class ${superClassName} extends ${baseClassName} { super.readState(in); #foreach( $attr in ${object.DeclaredAttributes} ) #set ( $name = "$stringUtils.formatVariableName(${attr.Name})") -#set ( $type = "$importUtils.formatJavaType(${attr.Type})") +#set ( $type = "$importUtils.formatJavaType(${attr.Type}, $attr.isMandatory())") #if($importUtils.isPrimitive($type)) this.$name = in.read${stringUtils.capitalized($type)}(); #else diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/OptimisticLockingIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/OptimisticLockingIT.java index a34b803224..f389f34e93 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/access/OptimisticLockingIT.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/access/OptimisticLockingIT.java @@ -20,6 +20,7 @@ package org.apache.cayenne.access; import org.apache.cayenne.di.Inject; +import org.apache.cayenne.query.ObjectSelect; import org.apache.cayenne.query.Ordering; import org.apache.cayenne.query.SelectQuery; import org.apache.cayenne.query.SortOrder; @@ -58,8 +59,8 @@ public class OptimisticLockingIT extends ServerCase { @Before public void setUp() throws Exception { tSimpleLockingTest = new TableHelper(dbHelper, "SIMPLE_LOCKING_TEST"); - tSimpleLockingTest.setColumns("LOCKING_TEST_ID", "NAME", "DESCRIPTION") - .setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.VARCHAR); + tSimpleLockingTest.setColumns("LOCKING_TEST_ID", "NAME", "DESCRIPTION", "INT_COLUMN_NOTNULL") + .setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER); tRelLockingTest = new TableHelper(dbHelper, "REL_LOCKING_TEST"); tRelLockingTest.setColumns( @@ -72,33 +73,21 @@ public void setUp() throws Exception { } protected void createSimpleLockingDataSet() throws Exception { - tLockingHelper.delete().execute(); - tRelLockingTest.delete().execute(); - tSimpleLockingTest.delete().execute(); - tSimpleLockingTest.insert(1, "LockTest1", null); + tSimpleLockingTest.insert(1, "LockTest1", null, 1); } protected void createLockingOnNullDataSet() throws Exception { - tLockingHelper.delete().execute(); - tRelLockingTest.delete().execute(); - tSimpleLockingTest.delete().execute(); - tSimpleLockingTest.insert(1, null, null); + tSimpleLockingTest.insert(1, null, null, 0); } protected void createLockingOnMixedDataSet() throws Exception { - tLockingHelper.delete().execute(); - tRelLockingTest.delete().execute(); - tSimpleLockingTest.delete().execute(); - tSimpleLockingTest.insert(1, null, null); - tSimpleLockingTest.insert(2, "LockTest2", null); - tSimpleLockingTest.insert(3, "LockTest3", "Another Lock Test"); + tSimpleLockingTest.insert(1, null, null, 1); + tSimpleLockingTest.insert(2, "LockTest2", null, 2); + tSimpleLockingTest.insert(3, "LockTest3", "Another Lock Test", 3); } protected void createLockingOnToOneDataSet() throws Exception { - tLockingHelper.delete().execute(); - tRelLockingTest.delete().execute(); - tSimpleLockingTest.delete().execute(); - tSimpleLockingTest.insert(1, "LockTest1", null); + tSimpleLockingTest.insert(1, "LockTest1", null, 2); tRelLockingTest.insert(5, 1, "Rel Test 1"); tLockingHelper.insert(1, 5, "Locking Helper 1"); } @@ -264,6 +253,27 @@ public void testSuccessSimpleLockingOnUpdate() throws Exception { context.commitChanges(); } + @Test + public void testSuccessSimpleLockingNullablePrimitiveColumn() throws Exception { + createSimpleLockingDataSet(); + + SimpleLockingTestEntity object = ObjectSelect.query(SimpleLockingTestEntity.class).selectOne(context); + + // we should have NULL value in primitive column + assertEquals(0, object.getIntColumnNull()); + assertNull(object.readPropertyDirectly("intColumnNull")); + + // change object and save... no optimistic lock failure expected + object.setDescription("first update"); + object.setIntColumnNotnull(2); + context.commitChanges(); + + // update values once more + object.setDescription("second update"); + object.setIntColumnNull(3); + context.commitChanges(); + } + @Test public void testSuccessSimpleLockingOnUpdateFollowedByInvalidate() throws Exception { createSimpleLockingDataSet(); diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/locking/auto/_SimpleLockingTestEntity.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/locking/auto/_SimpleLockingTestEntity.java index a74e3129c2..47ce6e0bfe 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/testdo/locking/auto/_SimpleLockingTestEntity.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/locking/auto/_SimpleLockingTestEntity.java @@ -20,9 +20,13 @@ public abstract class _SimpleLockingTestEntity extends BaseDataObject { public static final String LOCKING_TEST_ID_PK_COLUMN = "LOCKING_TEST_ID"; public static final Property DESCRIPTION = Property.create("description", String.class); + public static final Property INT_COLUMN_NOTNULL = Property.create("intColumnNotnull", Integer.class); + public static final Property INT_COLUMN_NULL = Property.create("intColumnNull", Integer.class); public static final Property NAME = Property.create("name", String.class); protected String description; + protected int intColumnNotnull; + protected Integer intColumnNull; protected String name; @@ -36,6 +40,29 @@ public String getDescription() { return this.description; } + public void setIntColumnNotnull(int intColumnNotnull) { + beforePropertyWrite("intColumnNotnull", this.intColumnNotnull, intColumnNotnull); + this.intColumnNotnull = intColumnNotnull; + } + + public int getIntColumnNotnull() { + beforePropertyRead("intColumnNotnull"); + return this.intColumnNotnull; + } + + public void setIntColumnNull(int intColumnNull) { + beforePropertyWrite("intColumnNull", this.intColumnNull, intColumnNull); + this.intColumnNull = intColumnNull; + } + + public int getIntColumnNull() { + beforePropertyRead("intColumnNull"); + if(this.intColumnNull == null) { + return 0; + } + return this.intColumnNull; + } + public void setName(String name) { beforePropertyWrite("name", this.name, name); this.name = name; @@ -55,6 +82,10 @@ public Object readPropertyDirectly(String propName) { switch(propName) { case "description": return this.description; + case "intColumnNotnull": + return this.intColumnNotnull; + case "intColumnNull": + return this.intColumnNull; case "name": return this.name; default: @@ -72,6 +103,12 @@ public void writePropertyDirectly(String propName, Object val) { case "description": this.description = (String)val; break; + case "intColumnNotnull": + this.intColumnNotnull = val == null ? 0 : (int)val; + break; + case "intColumnNull": + this.intColumnNull = (Integer)val; + break; case "name": this.name = (String)val; break; @@ -92,6 +129,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE protected void writeState(ObjectOutputStream out) throws IOException { super.writeState(out); out.writeObject(this.description); + out.writeInt(this.intColumnNotnull); + out.writeObject(this.intColumnNull); out.writeObject(this.name); } @@ -99,6 +138,8 @@ protected void writeState(ObjectOutputStream out) throws IOException { protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException { super.readState(in); this.description = (String)in.readObject(); + this.intColumnNotnull = in.readInt(); + this.intColumnNull = (Integer)in.readObject(); this.name = (String)in.readObject(); } diff --git a/cayenne-server/src/test/java/org/apache/cayenne/testdo/primitive/auto/_PrimitivesTestEntity.java b/cayenne-server/src/test/java/org/apache/cayenne/testdo/primitive/auto/_PrimitivesTestEntity.java index 6750a4f33c..1493844f57 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/testdo/primitive/auto/_PrimitivesTestEntity.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/testdo/primitive/auto/_PrimitivesTestEntity.java @@ -23,8 +23,8 @@ public abstract class _PrimitivesTestEntity extends BaseDataObject { public static final Property CHAR_COLUMN = Property.create("charColumn", Character.class); public static final Property INT_COLUMN = Property.create("intColumn", Integer.class); - protected boolean booleanColumn; - protected char charColumn; + protected Boolean booleanColumn; + protected Character charColumn; protected int intColumn; @@ -35,6 +35,9 @@ public void setBooleanColumn(boolean booleanColumn) { public boolean isBooleanColumn() { beforePropertyRead("booleanColumn"); + if(this.booleanColumn == null) { + return false; + } return this.booleanColumn; } @@ -45,6 +48,9 @@ public void setCharColumn(char charColumn) { public char getCharColumn() { beforePropertyRead("charColumn"); + if(this.charColumn == null) { + return 0; + } return this.charColumn; } @@ -84,13 +90,13 @@ public void writePropertyDirectly(String propName, Object val) { switch (propName) { case "booleanColumn": - this.booleanColumn = val == null ? false : (Boolean)val; + this.booleanColumn = (Boolean)val; break; case "charColumn": - this.charColumn = val == null ? 0 : (Character)val; + this.charColumn = (Character)val; break; case "intColumn": - this.intColumn = val == null ? 0 : (Integer)val; + this.intColumn = val == null ? 0 : (int)val; break; default: super.writePropertyDirectly(propName, val); @@ -108,14 +114,16 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE @Override protected void writeState(ObjectOutputStream out) throws IOException { super.writeState(out); - out.writeBoolean(this.booleanColumn); + out.writeObject(this.booleanColumn); + out.writeObject(this.charColumn); out.writeInt(this.intColumn); } @Override protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException { super.readState(in); - this.booleanColumn = in.readBoolean(); + this.booleanColumn = (Boolean)in.readObject(); + this.charColumn = (Character)in.readObject(); this.intColumn = in.readInt(); } diff --git a/cayenne-server/src/test/resources/cayenne-locking.xml b/cayenne-server/src/test/resources/cayenne-locking.xml index 7a12f1dbfe..8a7c266023 100644 --- a/cayenne-server/src/test/resources/cayenne-locking.xml +++ b/cayenne-server/src/test/resources/cayenne-locking.xml @@ -1,5 +1,7 @@ diff --git a/cayenne-server/src/test/resources/cayenne-primitive.xml b/cayenne-server/src/test/resources/cayenne-primitive.xml index 35c4154d88..9ec85b7180 100644 --- a/cayenne-server/src/test/resources/cayenne-primitive.xml +++ b/cayenne-server/src/test/resources/cayenne-primitive.xml @@ -1,5 +1,7 @@ diff --git a/cayenne-server/src/test/resources/locking.map.xml b/cayenne-server/src/test/resources/locking.map.xml index 54df6d16af..cba073cbaa 100644 --- a/cayenne-server/src/test/resources/locking.map.xml +++ b/cayenne-server/src/test/resources/locking.map.xml @@ -16,6 +16,8 @@ + + @@ -27,6 +29,8 @@ + + diff --git a/cayenne-server/src/test/resources/primitive.map.xml b/cayenne-server/src/test/resources/primitive.map.xml index 965b7176d2..35df1d7b5f 100644 --- a/cayenne-server/src/test/resources/primitive.map.xml +++ b/cayenne-server/src/test/resources/primitive.map.xml @@ -12,7 +12,7 @@ - + diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java index b914b9b7b6..c72934df38 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java @@ -39,6 +39,7 @@ public class CodeTemplateManager { public static final String STANDARD_SERVER_SUPERCLASS = "Standard Server Superclass"; public static final String STANDARD_SERVER_SUBCLASS = "Standard Server Subclass"; + public static final String SINGLE_SERVER_CLASS = "Single Server class"; static final String STANDARD_CLIENT_SUPERCLASS = "Standard Client Superclass"; static final String STANDARD_CLIENT_SUBCLASS = "Standard Client Subclass"; @@ -64,6 +65,7 @@ public CodeTemplateManager(Application application) { standardSubclassTemplates = new ArrayList<>(3); standardSubclassTemplates.add(STANDARD_SERVER_SUBCLASS); standardSubclassTemplates.add(STANDARD_CLIENT_SUBCLASS); + standardSubclassTemplates.add(SINGLE_SERVER_CLASS); updateCustomTemplates(getTemplatePreferences(application)); @@ -72,23 +74,23 @@ public CodeTemplateManager(Application application) { standardTemplates.put(STANDARD_CLIENT_SUPERCLASS, ClientClassGenerationAction.SUPERCLASS_TEMPLATE); standardTemplates.put(STANDARD_SERVER_SUBCLASS, ClassGenerationAction.SUBCLASS_TEMPLATE); standardTemplates.put(STANDARD_CLIENT_SUBCLASS, ClientClassGenerationAction.SUBCLASS_TEMPLATE); + standardTemplates.put(SINGLE_SERVER_CLASS, ClassGenerationAction.SINGLE_CLASS_TEMPLATE); } /** * Updates custom templates from preferences. */ public void updateCustomTemplates(Preferences preference) { - String[] keys = null; + String[] keys = {}; try { keys = preference.childrenNames(); } catch (BackingStoreException e) { logger.warn("Error reading preferences"); } this.customTemplates = new HashMap<>(keys.length, 1); - - for (int j = 0; j < keys.length; j++) { - FSPath path = new FSPath(preference.node(keys[j])); - customTemplates.put(keys[j], path.getPath()); + for (String key : keys) { + FSPath path = new FSPath(preference.node(key)); + customTemplates.put(key, path.getPath()); } } From 6c871b3f68294a909b5feb573e237cd0fada753e Mon Sep 17 00:00:00 2001 From: Nikita Timofeev Date: Wed, 27 Sep 2017 14:11:04 +0300 Subject: [PATCH 2/2] Use boxed types for nullable primitive fields --- .../translator/batch/InsertBatchTranslatorIT.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslatorIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslatorIT.java index ce66e95e64..93371f2adc 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslatorIT.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslatorIT.java @@ -71,7 +71,7 @@ public void testCreateSqlString() throws Exception { InsertBatchTranslator builder = new InsertBatchTranslator(insertQuery, adapter); String generatedSql = builder.getSql(); assertNotNull(generatedSql); - assertEquals("INSERT INTO " + entity.getName() + " (DESCRIPTION, LOCKING_TEST_ID, NAME) VALUES (?, ?, ?)", + assertEquals("INSERT INTO " + entity.getName() + " (DESCRIPTION, INT_COLUMN_NOTNULL, INT_COLUMN_NULL, LOCKING_TEST_ID, NAME) VALUES (?, ?, ?, ?, ?)", generatedSql); } @@ -91,9 +91,12 @@ public void testCreateSqlStringWithIdentifiersQuote() throws Exception { String charStart = unitAdapter.getIdentifiersStartQuote(); String charEnd = unitAdapter.getIdentifiersEndQuote(); assertNotNull(generatedSql); - assertEquals("INSERT INTO " + charStart + entity.getName() + charEnd + " (" + charStart + "DESCRIPTION" - + charEnd + ", " + charStart + "LOCKING_TEST_ID" + charEnd + ", " + charStart + "NAME" + charEnd - + ") VALUES (?, ?, ?)", generatedSql); + assertEquals("INSERT INTO " + charStart + entity.getName() + charEnd + + " (" + charStart + "DESCRIPTION" + charEnd + ", " + + charStart + "INT_COLUMN_NOTNULL" + charEnd + ", " + + charStart + "INT_COLUMN_NULL" + charEnd + ", " + + charStart + "LOCKING_TEST_ID" + charEnd + ", " + + charStart + "NAME" + charEnd + ") VALUES (?, ?, ?, ?, ?)", generatedSql); } finally { entity.getDataMap().setQuotingSQLIdentifiers(false); }