+ private String getLatestInsertedId(Connection aConnection) throws SQLException {
+ if (primaryKeySequence==null)
+ primaryKeySequence = mainTable+"_id_seq";
+
+ PreparedStatement statement = aConnection.prepareStatement("select currval('" + primaryKeySequence + "')");
+
+ ResultSet rs = statement.executeQuery();
+ rs.next();
+ return rs.getString(1);