Skip to content

Commit 4eb83fc

Browse files
committed
HHH-19671 - Avoid issuing a callback warning when a class defines an IdClass and has lifecycle callbacks
Signed-off-by: Jan Schatteman <[email protected]>
1 parent 5595894 commit 4eb83fc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hibernate-core/src/main/java/org/hibernate/jpa/event/internal/CallbackDefinitionResolver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import jakarta.persistence.ExcludeSuperclassListeners;
3333
import jakarta.persistence.MappedSuperclass;
3434
import jakarta.persistence.PersistenceException;
35+
import org.hibernate.spi.NavigablePath;
3536

3637
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
3738
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
@@ -282,7 +283,10 @@ public static void resolveLifecycleCallbacks(
282283
// code was added by HHH-12326
283284
collector.addSecondPass( persistentClasses -> {
284285
for ( Property property : persistentClass.getDeclaredProperties() ) {
285-
if ( property.isComposite() ) {
286+
if ( property.isComposite()
287+
// this is to avoid issuing an embeddableLifecycleCallback warning in case the embedded property represents an IdClass (see HHH-19671)
288+
// alternative way: collector.getClassDetailsRegistry().getClassDetails( property.getType().getReturnedClass().getName() ).hasDirectAnnotationUsage( IdClass.class )
289+
&& !NavigablePath.IDENTIFIER_MAPPER_PROPERTY.equals(property.getName()) ) {
286290
try {
287291
final Class<?> mappedClass = persistentClass.getMappedClass();
288292
for ( CallbackType type : CallbackType.values() ) {

0 commit comments

Comments
 (0)