Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -4622,6 +4622,16 @@ public boolean supportsPartitionBy() {
return false;
}

/**
* Does this dialect require that the columns listed in
* {@code partition by} also occur in the primary key?
*
* @since 7.1
*/
public boolean addPartitionKeyToPrimaryKey() {
return false;
}

/**
* Override {@link DatabaseMetaData#supportsNamedParameters()}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,16 @@ public String getSelectGUIDString() {
return "select uuid()";
}

@Override
public boolean supportsPartitionBy() {
return true;
}

@Override
public boolean addPartitionKeyToPrimaryKey() {
return true;
}

@Override
public boolean supportsCommentOn() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ public boolean supportsPartitionBy() {
return true;
}

@Override
public boolean addPartitionKeyToPrimaryKey() {
return true;
}

@Override
public boolean supportsNonQueryWithCTE() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public boolean isColumnInsertable(int index) {
public boolean isColumnUpdateable(int index) {
return true;
}

@Override
public boolean isPartitionKey() {
return false;
}
} );
return column;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,4 +897,9 @@ public Supplier<? extends Expectation> getDeleteAllExpectation() {
public void setDeleteAllExpectation(Supplier<? extends Expectation> deleteAllExpectation) {
this.deleteAllExpectation = deleteAllExpectation;
}

@Override
public boolean isPartitionKey() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,9 @@ public boolean isColumnUpdateable(int index) {
public String toString() {
return getClass().getSimpleName();
}

@Override
public boolean isPartitionKey() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,22 @@ public void createPrimaryKey() {
final PrimaryKey pk = new PrimaryKey( table );
pk.setName( PK_ALIAS.toAliasString( table.getName() ) );
pk.addColumns( getKey() );

if ( addPartitionKeyToPrimaryKey() ) {
for ( Property property : getProperties() ) {
if ( property.getValue().isPartitionKey() ) {
pk.addColumns( property.getValue() );
}
}
}
table.setPrimaryKey( pk );
}

private boolean addPartitionKeyToPrimaryKey() {
return metadataBuildingContext.getMetadataCollector()
.getDatabase().getDialect()
.addPartitionKeyToPrimaryKey();
}

public abstract String getWhere();

public int getBatchSize() {
Expand Down
2 changes: 2 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/mapping/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ private Type getIdType(EntityType entityType) {

boolean isAlternateUniqueKey();

boolean isPartitionKey();

boolean isNullable();

void createForeignKey();
Expand Down
Loading