Skip to content
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

Add support for discovering JPA @Entity used as meta-annotation during scanning #29636

Closed
kumar-csice opened this issue Dec 5, 2022 · 2 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@kumar-csice
Copy link

kumar-csice commented Dec 5, 2022

Overview

I have already reported this issue on Stack Overflow.

Desc : Spring JPA does not recognize my custom @MyEntity annotation instead of @javax.persistence.Entity annotation.

Related Issues

Expectations

Existing:

public class DefaultPersistenceUnitManager
		implements PersistenceUnitManager, ResourceLoaderAware, LoadTimeWeaverAware, InitializingBean {

private static final Set<AnnotationTypeFilter> entityTypeFilters;
static {
		entityTypeFilters = new LinkedHashSet<>(8);
		entityTypeFilters.add(new AnnotationTypeFilter(Entity.class, false));
		entityTypeFilters.add(new AnnotationTypeFilter(Embeddable.class, false));
		entityTypeFilters.add(new AnnotationTypeFilter(MappedSuperclass.class, false));
		entityTypeFilters.add(new AnnotationTypeFilter(Converter.class, false));
	}

To be:

static {
	entityTypeFilters = new LinkedHashSet<>(8);
	entityTypeFilters.add(new AnnotationTypeFilter(Entity.class, false));
	entityTypeFilters.add(new AnnotationTypeFilter(Embeddable.class, false));
	entityTypeFilters.add(new AnnotationTypeFilter(MappedSuperclass.class, false));
	entityTypeFilters.add(new AnnotationTypeFilter(Converter.class, false));
	entityTypeFilters.add(new AnnotationTypeFilter(MyEntity.class, false)); // ADDED
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 5, 2022
@kumar-csice kumar-csice changed the title Add support for discovering JPA @CustomAnnotation during scanning Add support for discovering JPA @CustomEntity Annotation during scanning Dec 5, 2022
@sbrannen sbrannen changed the title Add support for discovering JPA @CustomEntity Annotation during scanning Add support for discovering JPA @Entity used as meta-annotation during scanning Jan 31, 2023
@sbrannen sbrannen added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Jan 31, 2023
@sbrannen
Copy link
Member

sbrannen commented Jan 31, 2023

As a side note, if were to make any changes in this area, we would never be able to make Spring's code directly dependent on a custom type from your project.

Rather, we would likely introduce support for finding @Entity when used as a meta-annotation; however, I am not sure that JPA/Hibernate support that. In any case, no JPA provider would support Spring's @AliasFor annotation as suggested in the linked Stack Overflow question.

@sbrannen
Copy link
Member

Since we are not aware of any JPA provider that supports @Entity when used as meta-annotation, we are closing this issue.

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2023
@sbrannen sbrannen added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 31, 2023
@sbrannen sbrannen self-assigned this Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants