Skip to content

Commit

Permalink
Reuse TypeInformation during PersistentPropertyPath and `Persiste…
Browse files Browse the repository at this point in the history
…ntEntity` lookups.

We now avoid Class -> TypeInformation conversion if we already have TypeInformation at hand.

Closes #1679
  • Loading branch information
mp911de committed Nov 29, 2023
1 parent d15359b commit ee01650
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public MappingJdbcConverter(RelationalMappingContext context, RelationResolver r
}

@Nullable
private Class<?> getEntityColumnType(Class<?> type) {
private Class<?> getEntityColumnType(TypeInformation<?> type) {

RelationalPersistentEntity<?> persistentEntity = getMappingContext().getPersistentEntity(type);

Expand Down Expand Up @@ -153,7 +153,7 @@ private Class<?> doGetColumnType(RelationalPersistentProperty property) {
}

if (property.isEntity()) {
Class<?> columnType = getEntityColumnType(property.getActualType());
Class<?> columnType = getEntityColumnType(property.getTypeInformation().getActualType());

if (columnType != null) {
return columnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ private SqlIdentifier getColumnNameToSortBy(Sort.Order order) {
}

PersistentPropertyPath<RelationalPersistentProperty> persistentPropertyPath = mappingContext
.getPersistentPropertyPath(order.getProperty(), entity.getType());
.getPersistentPropertyPath(order.getProperty(), entity.getTypeInformation());

propertyToSortBy = persistentPropertyPath.getBaseProperty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private <S, T> SqlIdentifierParameterSource getParameterSource(@Nullable S insta
if (property.isEmbedded()) {

Object value = propertyAccessor.getProperty(property);
RelationalPersistentEntity<?> embeddedEntity = context.getPersistentEntity(property.getType());
RelationalPersistentEntity<?> embeddedEntity = context.getPersistentEntity(property.getTypeInformation());
SqlIdentifierParameterSource additionalParameters = getParameterSource((T) value,
(RelationalPersistentEntity<T>) embeddedEntity, prefix + property.getEmbeddedPrefix(), skipProperty);
parameters.addAll(additionalParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ protected <S> S readAggregate(ConversionContext context, RowDocumentAccessor doc
return context.convert(documentAccessor, typeHint);
}

RelationalPersistentEntity<?> entity = getMappingContext().getPersistentEntity(rawType);
RelationalPersistentEntity<?> entity = getMappingContext().getPersistentEntity(typeHint);

if (entity == null) {
throw new MappingException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public AggregatePath getParentPath() {
public AggregatePath append(RelationalPersistentProperty property) {

PersistentPropertyPath<? extends RelationalPersistentProperty> newPath = isRoot() //
? context.getPersistentPropertyPath(property.getName(), rootType.getType()) //
? context.getPersistentPropertyPath(property.getName(), rootType.getTypeInformation()) //
: context.getPersistentPropertyPath(path.toDotPath() + "." + property.getName(),
path.getBaseProperty().getOwner().getType());
path.getBaseProperty().getOwner().getTypeInformation());

return context.getAggregatePath(newPath);
}
Expand Down Expand Up @@ -171,7 +171,8 @@ public PersistentPropertyPath<RelationalPersistentProperty> getRequiredPersisten

@Override
public RelationalPersistentEntity<?> getLeafEntity() {
return isRoot() ? rootType : context.getPersistentEntity(getRequiredLeafProperty().getActualType());
return isRoot() ? rootType
: context.getPersistentEntity(getRequiredLeafProperty().getTypeInformation().getActualType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public boolean isMultiValued() {
*/
@Nullable
public RelationalPersistentEntity<?> getLeafEntity() {
return path == null ? entity : context.getPersistentEntity(path.getLeafProperty().getActualType());
return path == null ? entity
: context.getPersistentEntity(path.getLeafProperty().getTypeInformation().getActualType());
}

/**
Expand Down Expand Up @@ -363,8 +364,8 @@ public Class<?> getQualifierColumnType() {
public PersistentPropertyPathExtension extendBy(RelationalPersistentProperty property) {

PersistentPropertyPath<? extends RelationalPersistentProperty> newPath = path == null //
? context.getPersistentPropertyPath(property.getName(), entity.getType()) //
: context.getPersistentPropertyPath(path.toDotPath() + "." + property.getName(), entity.getType());
? context.getPersistentPropertyPath(property.getName(), entity.getTypeInformation()) //
: context.getPersistentPropertyPath(path.toDotPath() + "." + property.getName(), entity.getTypeInformation());

return new PersistentPropertyPathExtension(context, newPath);
}
Expand Down

0 comments on commit ee01650

Please sign in to comment.