Skip to content

Make supporting @TypeAlias the default behavior #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mikereiche opened this issue Apr 2, 2021 · 0 comments · Fixed by #1120
Closed

Make supporting @TypeAlias the default behavior #1119

mikereiche opened this issue Apr 2, 2021 · 0 comments · Fixed by #1120
Assignees
Labels
type: enhancement A general enhancement

Comments

@mikereiche
Copy link
Collaborator

mikereiche commented Apr 2, 2021

Make supporting @\TypeAlias the default behavior. This currently requires a CustomMappingCouchbaseConverter which uses a TypeBasedTypeMapper which uses a TypeAwareInformationMapper - see src/test/java/org/springframework/data/couchbase/domain/Config

By packaging and using that TypeAwareInformationMapper (that considers @\TypeAlias) instead of Simple

	public DefaultCouchbaseTypeMapper(final String typeKey) {
		//super(new CouchbaseDocumentTypeAliasAccessor(typeKey));
		super(new CouchbaseDocumentTypeAliasAccessor(typeKey), (MappingContext)null, Collections.singletonList(new TypeAwareTypeInformationMapper()));
		this.typeKey = typeKey;
	}

override this:

public Alias createAliasFor(TypeInformation<?> type) {
    return Alias.of(type.getType().getName());
 }

with this:

@Override
public Alias createAliasFor(TypeInformation<?> type) {
	TypeAlias[] typeAlias = type.getType().getAnnotationsByType(TypeAlias.class);
		if (typeAlias.length == 1) {
		return Alias.of(typeAlias[0].value());
	}
	return super.createAliasFor(type);
}
@mikereiche mikereiche self-assigned this Apr 2, 2021
@mikereiche mikereiche added the type: enhancement A general enhancement label Apr 2, 2021
mikereiche added a commit that referenced this issue Apr 5, 2021
DefaultCouchbaseTypeMapper uses TypeAlias annotation if present.
Test case also uncovered that TypeAlias was being ignored for
string queries.

Closes #1119.
mikereiche added a commit that referenced this issue Apr 6, 2021
DefaultCouchbaseTypeMapper uses TypeAlias annotation if present.
Test case also uncovered that TypeAlias was being ignored for
string queries.

Closes #1119.
Original pull request: #1120.

Co-authored-by: mikereiche <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
1 participant