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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public Object getIdentifier() {

@Override
public String getMessage() {
return super.getMessage() + ": " + infoString( entityName, identifier );
return super.getMessage() + " for entity " + infoString( entityName, identifier );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public String getPropertyName() {

@Override
public String getMessage() {
return super.getMessage() + ": " + qualify( entityName, propertyName );
return super.getMessage() + " for entity " + qualify( entityName, propertyName );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object getIdentifier() {
}

public String getMessage() {
return super.getMessage() + ": " + infoString( entityName, identifier );
return super.getMessage() + " for entity " + infoString( entityName, identifier );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getPropertyName() {

@Override
public String getMessage() {
return super.getMessage() + ": "
return super.getMessage() + " for entity "
+ qualify( propertyOwnerEntityName, propertyName ) + " -> " + transientEntityName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getEntityName() {

@Override
public String getMessage() {
return super.getMessage() + ": " + infoString( entityName, identifier );
return super.getMessage() + " for entity " + infoString( entityName, identifier );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class NaturalIdHelper {
public static String[] getNaturalIdPropertyNames(EntityPersister persister) {
final int[] naturalIdPropertyIndices = persister.getNaturalIdentifierProperties();
if ( naturalIdPropertyIndices == null ) {
throw new IdentifierGenerationException( "entity '" + persister.getEntityName()
throw new IdentifierGenerationException( "Entity '" + persister.getEntityName()
+ "' has no '@NaturalId' property" );
}
if ( persister.getEntityMetamodel().isNaturalIdentifierInsertGenerated() ) {
throw new IdentifierGenerationException( "entity '" + persister.getEntityName()
throw new IdentifierGenerationException( "Entity '" + persister.getEntityName()
+ "' has a '@NaturalId' property which is also defined as insert-generated" );
}
final String[] allPropertyNames = persister.getPropertyNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ else if ( !allowMutation ) {
LOG.lazyPropertyFetchingAvailable( name );
}

lazy = persistentClass.isLazy() && (
lazy = persistentClass.isLazy()
// TODO: this disables laziness even in non-pojo entity modes:
!persistentClass.hasPojoRepresentation() || !isFinalClass( persistentClass.getProxyInterface() ) )
|| bytecodeEnhancementMetadata.isEnhancedForLazyLoading();
&& (!persistentClass.hasPojoRepresentation() || !isFinalClass( persistentClass.getProxyInterface() ) )
|| bytecodeEnhancementMetadata.isEnhancedForLazyLoading();

mutable = persistentClass.isMutable();
if ( persistentClass.isAbstract() == null ) {
Expand All @@ -451,18 +451,24 @@ && isAbstractClass( persistentClass.getMappedClass() ) ) {

polymorphic = persistentClass.isPolymorphic();
inherited = persistentClass.isInherited();
superclass = inherited ?
persistentClass.getSuperclass().getEntityName() :
null;
superclass = inherited
? persistentClass.getSuperclass().getEntityName()
: null;
hasSubclasses = persistentClass.hasSubclasses();

optimisticLockStyle = persistentClass.getOptimisticLockStyle();
final boolean isAllOrDirty = optimisticLockStyle.isAllOrDirty();
if ( isAllOrDirty && !dynamicUpdate ) {
throw new MappingException( "optimistic-lock=all|dirty requires dynamic-update=\"true\": " + name );
}
if ( versionPropertyIndex != NO_VERSION_INDX && isAllOrDirty ) {
throw new MappingException( "version and optimistic-lock=all|dirty are not a valid combination : " + name );
//TODO: move these checks into the Binders
if ( optimisticLockStyle.isAllOrDirty() ) {
if ( !dynamicUpdate ) {
throw new MappingException( "Entity '" + name
+ "' has 'OptimisticLockType." + optimisticLockStyle
+ "' but is not annotated '@DynamicUpdate'" );
}
if ( versionPropertyIndex != NO_VERSION_INDX ) {
throw new MappingException( "Entity '" + name
+ "' has 'OptimisticLockType." + optimisticLockStyle
+ "' but declares a '@Version' field" );
}
}

hasCollections = foundCollection;
Expand Down Expand Up @@ -520,9 +526,8 @@ private void verifyNaturalIdProperty(Property property) {
final Value value = property.getValue();
if ( value instanceof ManyToOne toOne ) {
if ( toOne.getNotFoundAction() == NotFoundAction.IGNORE ) {
throw new MappingException(
"Attribute marked as natural-id can not also be a not-found association - "
+ propertyName( property )
throw new MappingException( "Association '" + propertyName( property )
+ "' marked as '@NaturalId' is also annotated '@NotFound(IGNORE)'"
);
}
}
Expand Down Expand Up @@ -585,7 +590,7 @@ private void mapPropertyToIndex(Property property, int i) {
*/
public boolean isNaturalIdentifierInsertGenerated() {
if ( naturalIdPropertyNumbers.length == 0 ) {
throw new IllegalStateException( "entity does not have a natural id: " + name );
throw new IllegalStateException( "Entity '" + name + "' does not have a natural id" );
}
for ( int i = 0; i < naturalIdPropertyNumbers.length; i++ ) {
final Generator strategy = generators[ naturalIdPropertyNumbers[i] ];
Expand Down Expand Up @@ -698,9 +703,9 @@ public NonIdentifierAttribute[] getProperties() {
}

public int getPropertyIndex(String propertyName) {
Integer index = getPropertyIndexOrNull(propertyName);
final Integer index = getPropertyIndexOrNull( propertyName );
if ( index == null ) {
throw new HibernateException("Unable to resolve property: " + propertyName);
throw new HibernateException( "Unable to resolve property: " + propertyName );
}
return index;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand All @@ -41,8 +40,7 @@ void checkManyToOne(ServiceRegistryScope registryScope) {
fail( "Expecting an exception" );
}
catch (MappingException expected) {
assertThat( expected.getMessage() )
.startsWith( "Attribute marked as natural-id can not also be a not-found association - " );
// expected
}
}

Expand All @@ -57,8 +55,7 @@ void checkEmbeddable(ServiceRegistryScope registryScope) {
fail( "Expecting an exception" );
}
catch (MappingException expected) {
assertThat( expected.getMessage() )
.startsWith( "Attribute marked as natural-id can not also be a not-found association - " );
// expected
}
}

Expand Down
Loading