Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(TYPE)
@Retention(RUNTIME)
public @interface NaturalIdClass {
Class<?> value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ public Column[] getOverriddenColumn(String propertyName) {
result = super.getOverriddenColumn( userPropertyName );
}
}
if ( result == null ) {
final String userPropertyName = extractUserPropertyName( "natural_id", propertyName );
if ( userPropertyName != null ) {
result = super.getOverriddenColumn( userPropertyName );
}
}
if ( result == null ) {
final String userPropertyName = extractUserPropertyName( IDENTIFIER_MAPPER_PROPERTY, propertyName );
if ( userPropertyName != null ) {
Expand All @@ -340,8 +346,8 @@ public Column[] getOverriddenColumn(String propertyName) {
}

private String extractUserPropertyName(String redundantString, String propertyName) {
String className = component.getOwner().getClassName();
boolean specialCase = propertyName.startsWith(className)
final String className = component.getOwner().getClassName();
final boolean specialCase = propertyName.startsWith(className)
&& propertyName.length() > className.length() + 2 + redundantString.length() // .id.
&& propertyName.substring( className.length() + 1, className.length() + 1 + redundantString.length() )
.equals(redundantString);
Expand Down
Loading