/** * Creates a DbDataUtil that will use the internal "raw" DB connection * of the EntityManager to perform data export and import. * @param emUtil Wrapper around an EntityManager instance */ public DbDataUtil(JuEmUtil emUtil) { this(emUtil.asConnUtil()); }
public DbSchemaUtil(JuEmUtil emUtil) { this(emUtil.asConnUtil()); }
/** * Gets a list of all sequence names of the DB. Sequences names are returned the * way the DB driver returns them, which is usually upper case. * @return List of Sequences names * @throws JuDbException If the list cannot be evaluated */ public List<String> getSequenceNames() throws JuDbException { // There doesn't seem to be a generic way to retrieve sequences using JDBC meta data, so // we have to use native queries. The queries are stored in the DB specific handlers. return this.getDbType().getDbSpecificHandler(this.asConnUtil()).getSequenceNames(); }
/** * Resets identity generation of all tables or sequences to allow for predictable * and repeatable entity generation. * <p> * The exact behaviour of identity generation may vary from DB to DB. * @param val Value for the next primary key */ public void resetIdentityGenerationOrSequences(int val) { this.getDbType().getDbSpecificHandler(this.asConnUtil()).resetIdentityGenerationOrSequences(val); }
public Long getNextValueFromSequence(String sequenceName) throws JuDbException { return this.getDbType().getDbSpecificHandler(this.asConnUtil()).getNextValueFromSequence(sequenceName); }
convertedColumn = this.emUtil.asConnUtil().getDbHandler().wrapInLowerString(mappedName); value = value.toString().toLowerCase();
/** * Gets a list of the primery key columns for the specified table * <p> * Column names are kept the way the driver returns them (may be upper, lower or mixed case) * @param tableName Table name * @return List of all columns that make up the primary key. If no primary key is applied, an empty list is returned. */ public List<String> getPrimaryKeyColumns(final String tableName) { final String actualTableName = this.getDbType().getDbSpecificHandler(this.asConnUtil()).convertTableNameCasing(tableName); List<String> columnNames = this.extractDatabaseMetaData(new DatabaseMetaDataCallback<List<String>>() { @Override public List<String> processMetaData(DatabaseMetaData dbmd) throws SQLException { ResultSet rs = dbmd.getPrimaryKeys(null, null, actualTableName); List<String> columnNames = new ArrayList<>(); while (rs.next()) { columnNames.add(rs.getString("COLUMN_NAME")); } rs.close(); return columnNames; } }); return columnNames; }