@@ -112,7 +112,7 @@ private static void generateContentClass(final String fileName, final String cla
112112 final StringBuilder sbBulkParams = new StringBuilder ();
113113 final StringBuilder sbBulkValues = new StringBuilder ();
114114
115- boolean hasPreviousPrimaryKey , hasPreviousInsertFields ;
115+ boolean hasPreviousPrimaryKey , hasAutoIncrementPrimaryKey , hasPreviousInsertFields ;
116116 boolean hasPreviousInsertDefaultValues , hasTextField ;
117117 boolean hasPreviousUpgradeElements ;
118118 int maxUpgradeVersion , minUpgradeWithoutChanges ;
@@ -129,6 +129,7 @@ private static void generateContentClass(final String fileName, final String cla
129129 sbBulkParams .setLength (0 );
130130 sbBulkValues .setLength (0 );
131131 hasPreviousPrimaryKey = false ;
132+ hasAutoIncrementPrimaryKey = false ;
132133 hasTextField = false ;
133134
134135 for (int i = 0 , n = tableData .fieldList .size (); i < n ; i ++) {
@@ -158,16 +159,28 @@ private static void generateContentClass(final String fileName, final String cla
158159 .append (fieldData .dbConstantName ).append (".getName() + \" \" + " )
159160 .append ("Columns." )
160161 .append (fieldData .dbConstantName ).append (".getType()" );
161- if (fieldData .dbIsAutoincrement ) {
162- sbCreateTable .append ("+ \" AUTOINCREMENT\" " );
163- }
164162 if (fieldData .dbIsPrimaryKey ) {
165- if (hasPreviousPrimaryKey ) {
166- sbCreateTablePrimaryKey .append (" + \" , \" + " );
163+ if (fieldData .dbIsAutoincrement ) {
164+ if (hasPreviousPrimaryKey ) {
165+ throw new IllegalArgumentException ("Not possible to have multiple" +
166+ " primary key fields if one of them is an autoincrement " +
167+ "field" );
168+ } else {
169+ hasAutoIncrementPrimaryKey = true ;
170+ sbCreateTable .append ("+ \" PRIMARY KEY AUTOINCREMENT\" " );
171+ }
172+ } else if (hasAutoIncrementPrimaryKey ) {
173+ throw new IllegalArgumentException ("Not possible to have multiple" +
174+ " primary key fields if one of them is an autoincrement " +
175+ "field" );
176+ } else {
177+ if (hasPreviousPrimaryKey ) {
178+ sbCreateTablePrimaryKey .append (" + \" , \" + " );
179+ }
180+ hasPreviousPrimaryKey = true ;
181+ sbCreateTablePrimaryKey .append ("Columns." )
182+ .append (fieldData .dbConstantName ).append (".getName()" );
167183 }
168- hasPreviousPrimaryKey = true ;
169- sbCreateTablePrimaryKey .append ("Columns." )
170- .append (fieldData .dbConstantName ).append (".getName()" );
171184 }
172185
173186 if (fieldData .dbHasIndex ) {
0 commit comments