protected void processSequence( InspectionContext inspectionContext, Schema schema, Column column, ResultSet sequences) throws SQLException { if (sequences.next()) { String name = sequences.getString("SEQUENCE_NAME"); Sequence sequence = schema.getSequence(name); if (sequence == null) { schema.addSequence(sequence = new Sequence(name)); } /** * Increments the LAST_VALUE by 1, as PostgreSQL LAST_VALUE number points to a value which is * already used by a table */ sequence.setLastValue((sequences.getLong("LAST_VALUE") + 1L)); sequence.setStartWith(sequences.getLong("START_VALUE")); sequence.setMinValue(sequences.getLong("MIN_VALUE")); sequence.setMaxValue(sequences.getLong("MAX_VALUE")); sequence.setIncrementBy(sequences.getLong("INCREMENT_BY")); sequence.setCache(sequences.getInt("CACHE_VALUE")); sequence.setCycle("T".equalsIgnoreCase(sequences.getString("IS_CYCLED"))); if (column != null) { column.setSequence(sequence); } inspectionContext.getInspectionResults().addObject(sequence); } }
@Override protected void processResultSet(InspectionContext inspectionContext, ResultSet sequences) throws SQLException { InspectionResults inspectionResults = inspectionContext.getInspectionResults(); if (sequences.next()) { Table table = addTable( inspectionResults, sequences.getString("table_catalog"), sequences.getString("table_schema"), sequences.getString("table_name")); Sequence sequence = new Sequence(); sequence.setStartWith(sequences.getLong("start_with")); sequence.setLastValue(sequences.getLong("last_value")); sequence.setIncrementBy(sequences.getLong("increment_by")); Column column = table.addColumn(sequences.getString("column_name")); column.setSequence(sequence); column.getTable().getSchema().addSequence(sequence); inspectionResults.addObject(sequence); } }