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 @@ -95,16 +95,16 @@ private void collectAttributeConversionInfo(Map<String, AttributeConversionInfo>
// collect superclass info first
collectAttributeConversionInfo( infoMap, entityClassDetails.getSuperClass() );

final var sourceModelContext = getSourceModelContext();
final var modelContext = getSourceModelContext();
final boolean canContainConvert =
entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, sourceModelContext )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, sourceModelContext )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, sourceModelContext );
entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, modelContext )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, modelContext )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, modelContext );
if ( ! canContainConvert ) {
return;
}

entityClassDetails.forEachAnnotationUsage( Convert.class, sourceModelContext, (usage) -> {
entityClassDetails.forEachAnnotationUsage( Convert.class, modelContext, (usage) -> {
final var info = new AttributeConversionInfo( usage, entityClassDetails );
if ( isEmpty( info.getAttributeName() ) ) {
throw new IllegalStateException( "@Convert placed on @Entity/@MappedSuperclass must define attributeName" );
Expand All @@ -120,9 +120,11 @@ public void startingProperty(MemberDetails property) {
if ( !attributeConversionInfoMap.containsKey( propertyName ) ) {
property.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final var info = new AttributeConversionInfo( usage, property );
final String path = isEmpty( info.getAttributeName() )
? propertyName
: propertyName + '.' + info.getAttributeName();
final String infoAttributeName = info.getAttributeName();
final String path =
isEmpty( infoAttributeName )
? propertyName
: propertyName + '.' + infoAttributeName;
attributeConversionInfoMap.put( path, info );
} );
}
Expand Down Expand Up @@ -166,7 +168,7 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails
//TODO handle quote and non quote table comparison
final String tableName = prop.getValue().getTable().getName();
if ( getJoinsPerRealTableName().containsKey( tableName ) ) {
final Join join = getJoinsPerRealTableName().get( tableName );
final var join = getJoinsPerRealTableName().get( tableName );
addPropertyToJoin( prop, memberDetails, declaringClass, join );
}
else {
Expand All @@ -180,14 +182,14 @@ public void addProperty(Property prop, MemberDetails memberDetails, ClassDetails

@Override
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
final Join join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation );
final var join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation );
joins = entityBinder.getSecondaryTables();
return join;
}

@Override
public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) {
final Join join = entityBinder.createJoin(
final var join = entityBinder.createJoin(
this,
noDelayInPkColumnCreation,
false,
Expand Down Expand Up @@ -289,10 +291,10 @@ static void prepareActualProperty(
}

// If the property depends on a type variable, we have to copy it and the Value
final Property actualProperty = property.copy();
final var actualProperty = property.copy();
actualProperty.setGeneric( true );
actualProperty.setReturnedClassName( memberDetails.getType().getName() );
final Value value = actualProperty.getValue().copy();
final var value = actualProperty.getValue().copy();
if ( value instanceof Collection collection ) {
if ( !allowCollections ) {
throw new AssertionFailure( "Collections are not allowed as identifier properties" );
Expand All @@ -301,13 +303,13 @@ static void prepareActualProperty(
// collection.setOwner( null );
collection.setRole( memberDetails.getDeclaringType().getName() + "." + property.getName() );
// To copy the element and key values, we need to defer setting the type name until the CollectionBinder ran
final Value originalValue = property.getValue();
final var originalValue = property.getValue();
context.getMetadataCollector().addSecondPass(
new SecondPass() {
@Override
public void doSecondPass(Map<String, PersistentClass> persistentClasses) {
final var initializedCollection = (Collection) originalValue;
final Value element = initializedCollection.getElement().copy();
final var element = initializedCollection.getElement().copy();
setTypeName( element, memberDetails.getElementType().getName() );
if ( initializedCollection instanceof IndexedCollection indexedCollection ) {
final Value index = indexedCollection.getIndex().copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public interface IdentifiableTypeClass extends TableContainer {

Table getImplicitTable();

/**
* @deprecated No longer used
*/
@Deprecated(since = "7.2", forRemoval = true)
void applyProperty(Property property);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ public List<Property> getDeclaredProperties() {
return declaredProperties;
}

public void addDeclaredProperty(Property p) {
public void addDeclaredProperty(Property property) {
//Do not add duplicate properties
//TODO is it efficient enough?
String name = p.getName();
final String name = property.getName();
for ( var declaredProperty : declaredProperties ) {
if ( name.equals( declaredProperty.getName() ) ) {
return;
}
}
declaredProperties.add(p);
declaredProperties.add( property );
}

public Class<?> getMappedClass() {
Expand Down Expand Up @@ -141,7 +140,7 @@ public Component getIdentifierMapper() {
if ( superMappedSuperclass != null ) {
propagatedMapper = superMappedSuperclass.getIdentifierMapper();
}
if (propagatedMapper == null && superPersistentClass != null){
if ( propagatedMapper == null && superPersistentClass != null ) {
propagatedMapper = superPersistentClass.getIdentifierMapper();
}
}
Expand Down Expand Up @@ -183,8 +182,8 @@ public boolean hasProperty(String name) {
*/
public boolean isPropertyDefinedInHierarchy(String name) {
return hasProperty( name )
|| getSuperMappedSuperclass() != null && getSuperMappedSuperclass().isPropertyDefinedInHierarchy( name )
|| getSuperPersistentClass() != null && getSuperPersistentClass().isPropertyDefinedInHierarchy( name );
|| superMappedSuperclass != null && superMappedSuperclass.isPropertyDefinedInHierarchy( name )
|| superPersistentClass != null && superPersistentClass.isPropertyDefinedInHierarchy( name );
}

public void prepareForMappingModel() {
Expand Down Expand Up @@ -228,7 +227,7 @@ public Table getImplicitTable() {
return implicitTable;
}

@Override
@Override @Deprecated(forRemoval = true)
public void applyProperty(Property property) {
assert property.getValue().getTable() != null
&& property.getValue().getTable().equals( getImplicitTable() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ public List<IdentifiableTypeClass> getSubTypes() {
throw new UnsupportedOperationException( "Not implemented yet" );
}

@Override
@Override @Deprecated(forRemoval = true)
public void applyProperty(Property property) {
final var table = property.getValue().getTable();
if ( table.equals( getImplicitTable() ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,18 +866,12 @@ public boolean hasAnyUpdatableColumns() {

@Override
public boolean isColumnInsertable(int index) {
if ( !insertability.isEmpty() ) {
return insertability.get( index );
}
return false;
return !insertability.isEmpty() && insertability.get( index );
}

@Override
public boolean isColumnUpdateable(int index) {
if ( !updatability.isEmpty() ) {
return updatability.get( index );
}
return false;
return !updatability.isEmpty() && updatability.get( index );
}

public boolean isPartitionKey() {
Expand Down