@Override protected PreparedStatement prepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys) throws SQLException { if (generatedKeys) { Collection<DbAttribute> generatedAttributes = query.getDbEntity().getGeneratedAttributes(); String[] generatedPKColumns = new String[generatedAttributes.size()]; int i = 0; for (DbAttribute generatedAttribute : generatedAttributes) { if (generatedAttribute.isPrimaryKey()) { generatedPKColumns[i++] = generatedAttribute.getName().toLowerCase(); } } return connection.prepareStatement(queryStr, Arrays.copyOf(generatedPKColumns, i)); } return connection.prepareStatement(queryStr); }
/** * Returns whether BatchQuery generates any keys. */ protected boolean hasGeneratedKeys() { // see if we are configured to support generated keys if (!adapter.supportsGeneratedKeys()) { return false; } // see if the query needs them if (query instanceof InsertBatchQuery) { // see if any of the generated attributes is PK Iterator attributes = query.getDbEntity().getGeneratedAttributes().iterator(); while (attributes.hasNext()) { if (((DbAttribute) attributes.next()).isPrimaryKey()) { return true; } } } return false; }
private void checkOnGeneratedStrategyConflict(DbRelationship relationship, ValidationResult validationResult) { if (relationship.isToDependentPK()) { Collection<DbAttribute> attributes = relationship.getTargetEntity().getGeneratedAttributes(); for (DbAttribute attribute : attributes) { if (attribute.isGenerated()) { addFailure( validationResult, relationship, "'To Dep Pk' incompatible with Database-Generated on '%s' relationship", toString(relationship)); } } } }
/** * Returns whether BatchQuery generates any keys. */ protected boolean hasGeneratedKeys() { // see if we are configured to support generated keys if (!dataNode.getAdapter().supportsGeneratedKeys()) { return false; } // see if the query needs them if (query instanceof InsertBatchQuery) { // see if any of the generated attributes is PK for (final DbAttribute attr : query.getDbEntity().getGeneratedAttributes()) { if (attr.isPrimaryKey()) { return true; } } } return false; }
Iterator it = batch.getDbEntity().getGeneratedAttributes().iterator(); while (it.hasNext()) { DbAttribute attribute = (DbAttribute) it.next();
for (DbAttribute attribute : batch.getDbEntity().getGeneratedAttributes()) {
Collection<DbAttribute> generated = query.getDbEntity().getGeneratedAttributes(); if (generated.size() == 1) { DbAttribute key = generated.iterator().next();