Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/main/java/com/dieselpoint/norm/sqlmakers/StandardSqlMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,33 +331,33 @@ public void populateGeneratedKey(ResultSet generatedKeys, Object insertRow) {
try {

Property prop = pojoInfo.getGeneratedColumnProperty();
boolean isInt = prop.dataType.isAssignableFrom(int.class); // int or long
Object newKey;

// if there is just one column, it's the generated key
// postgres returns multiple columns, though, so we have the fetch the value by name
int colCount = generatedKeys.getMetaData().getColumnCount();
if (colCount == 1) {
if(prop != null)
{
boolean isInt = prop.dataType.isAssignableFrom(int.class); // int or long
Object newKey;
// if there is just one column, it's the generated key
// postgres returns multiple columns, though, so we have the fetch the value by name
int colCount = generatedKeys.getMetaData().getColumnCount();
if (colCount == 1) {
if (isInt) {
newKey = generatedKeys.getInt(1);
} else {
newKey = generatedKeys.getLong(1);
}
} else {
} else {
// colcount > 1, must do by name
if (isInt) {
newKey = generatedKeys.getInt(prop.name);
} else {
newKey = generatedKeys.getLong(prop.name);
}
}

pojoInfo.putValue(insertRow, prop.name, newKey);
}

} catch (Throwable t) {
pojoInfo.putValue(insertRow, prop.name, newKey);
}
} catch (Throwable t) {
throw new DbException(t);
}
}
}


Expand Down