+
+ @Override
+ public long nextVal(Connection con, Sequence seq) throws SQLException
+ {
+ String sql = " SELECT NEXTVAL(?) ";
+
+ try (PreparedStatement ps = con.prepareStatement(sql))
+ {
+ ps.setString(1, seq.getName());
+
+ try (ResultSet rs = ps.executeQuery()) {
+ if (rs.next()) {
+ return rs.getLong(1);
+ }
+ }
+ }
+
+ throw new SQLException("No value returned for sequence: " + sql);
+ }
+
+
+ @Override
+ protected String typeName(Type type) {
+ // Special case: TIMESTAMPTZ stored as INTEGER (milliseconds since the epoch)
+ // Reading a TIMESTAMPTZ back from the DB, and converting it to a java.util.Date,
+ // is fraught with peril. The best way around this is to store the dates in
+ // milliseconds-since-the-epoch (01.01.1970 00:00:00.000 UTC).
+ if (Type.TIMESTAMPTZ.equals(type)) {
+ return "BIGINT";
+ }
+
+ return type.toString();
+ }}