mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-10 05:04:52 +00:00
HHH-16900 Rework also the MutationGroup APIs
This commit is contained in:
parent
fa677f3d62
commit
430929d3c3
@ -8,7 +8,6 @@
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
|
||||
@ -25,9 +24,9 @@ public interface MutationGroup {
|
||||
|
||||
int getNumberOfTableMutations();
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation();
|
||||
TableMutation getSingleTableMutation();
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName);
|
||||
TableMutation getTableMutation(String tableName);
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action);
|
||||
void forEachTableMutation(BiConsumer<Integer, TableMutation> action);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
import java.util.Locale;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
import org.hibernate.sql.model.ast.MutationGroup;
|
||||
@ -51,22 +50,19 @@ public int getNumberOfTableMutations() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation() {
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
public TableMutation getSingleTableMutation() {
|
||||
return tableMutation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName) {
|
||||
public TableMutation getTableMutation(String tableName) {
|
||||
assert tableMutation.getMutatingTable().getTableName().equals( tableName );
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
return tableMutation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action) {
|
||||
//noinspection unchecked
|
||||
action.accept( 0, (M) tableMutation );
|
||||
public void forEachTableMutation(BiConsumer<Integer, TableMutation> action) {
|
||||
action.accept( 0, tableMutation );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,6 @@
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
import org.hibernate.sql.model.ast.MutationGroup;
|
||||
@ -50,18 +49,17 @@ public int getNumberOfTableMutations() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation() {
|
||||
public TableMutation getSingleTableMutation() {
|
||||
throw new IllegalStateException( "Group contains multiple table mutations : " + mutationTarget.getNavigableRole() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName) {
|
||||
public TableMutation getTableMutation(String tableName) {
|
||||
for ( int i = 0; i < tableMutationList.size(); i++ ) {
|
||||
final TableMutation<?> tableMutation = tableMutationList.get( i );
|
||||
if ( tableMutation != null ) {
|
||||
if ( tableMutation.getMutatingTable().getTableName().equals( tableName ) ) {
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
return tableMutation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,10 +67,10 @@ public <O extends MutationOperation, M extends TableMutation<O>> M getTableMutat
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action) {
|
||||
public void forEachTableMutation(BiConsumer<Integer, TableMutation> action) {
|
||||
for ( int i = 0; i < tableMutationList.size(); i++ ) {
|
||||
//noinspection unchecked
|
||||
action.accept( i, (M)tableMutationList.get( i ) );
|
||||
action.accept( i, tableMutationList.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user