Skip to content

Commit 3312519

Browse files
mp911deschauder
authored andcommitted
Use IdentifiableType.hasSingleIdAttribute() to detect IdClass presence to obtain IdClass attributes.
We now use IdentifiableType.hasSingleIdAttribute() to detect whether a type should have an IdClass. hasSingleIdAttribute is defined to return false if an IdClass is being used. It could also return false in case multiple identifier attributes are in place (composite Id) which is a bit of a grey area. At least we avoid using Hibernate-specific API. Original pull request #2412 See #2330 Closes #2391
1 parent 90ffd03 commit 3312519

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@
3232
import org.eclipse.persistence.queries.ScrollableCursor;
3333
import org.hibernate.ScrollMode;
3434
import org.hibernate.ScrollableResults;
35-
import org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor;
3635
import org.hibernate.proxy.HibernateProxy;
36+
3737
import org.springframework.data.util.CloseableIterator;
3838
import org.springframework.lang.Nullable;
3939
import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -103,9 +103,7 @@ public Object getIdentifierFrom(Object entity) {
103103
*/
104104
@Override
105105
public <T> Set<SingularAttribute<? super T, ?>> getIdClassAttributes(IdentifiableType<T> type) {
106-
return type instanceof IdentifiableTypeDescriptor && ((IdentifiableTypeDescriptor<T>) type).hasIdClass()
107-
? super.getIdClassAttributes(type)
108-
: Collections.emptySet();
106+
return type.hasSingleIdAttribute() ? Collections.emptySet() : super.getIdClassAttributes(type);
109107
}
110108

111109
/*

0 commit comments

Comments
 (0)