Inconsistent handling of polymorphic entities with only a repository for the root entity type
@odrotbohm ci sta già lavorando.
Dal 31/8/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
If I define a hierarchy of entities, and a polymorphic repository only for the root entity, descendants of the root entity are included under the management of the polymorphic repository only if it exists at least another entity (with a repository) with a linkable association to the specific subclass.
For example, given the following:
@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = STRING)
public abstract class Address {
...
}
@Entity
@DiscriminatorValue("Residential")
public class ResidentialAddress extends Address {
}
@Entity
@DiscriminatorValue("Business")
public class BusinessAddress extends Address {
}
@Entity
public class Person {
...
@OneToOne(fetch = FetchType.LAZY)
private ResidentialAddress residentialAddress;
...
}
@RepositoryRestResource(path = "addresses", collectionResourceRel = "addresses")
public interface AddressRepository extends JpaRepository<Address, Long> {
}
@RepositoryRestResource(path = "people", collectionResourceRel = "people")
public interface PersonRepository extends JpaRepository<Person, Long> {
}
then, ResidentialAddress will be handled by the AddressRepository and its rels and href will reflect the ones specified on the AddressRepository.
The BusinessAddress, instead, while still returned by the AddressRepository, it will have rels and href generated using the Evo Inflector, which returns an invalid href for the links (businessAddress) which is not mapped and you will get a 500 if you tried to retrieve it under the link specified URL.
The following is an example of the payload returned by querying the collection resource '/addresses':
{
"_embedded" : {
"addresses" : [ {
"label" : "Home",
"address" : "The Elves",
"_links" : {
"self" : {
"href" : "http://localhost/addresses/1"
},
"address" : {
"href" : "http://localhost/addresses/1"
}
}
} ],
"businessAddresses" : [ {
"label" : "Holiday",
"address" : null,
"_links" : {
"self" : {
"href" : "http://localhost/businessAddress/2"
},
"businessAddress" : {
"href" : "http://localhost/businessAddress/2"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost/addresses"
},
"profile" : {
"href" : "http://localhost/profile/addresses"
}
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
My expectation is that entities in a hierarchy should be handled by their specific repository or by the next specified ancestor's repository.
This is a demo project demonstrating the issue: demo.zip
- Lingua principale
- Java
- Stelle
- 957
- Fork
- 570
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-projects/spring-data-rest
-
Release 5.0.9 (2025.1.9)Apertatype: task
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
spring-projects/spring-data-rest#2624 ·
-
Release 5.1.3 (2026.0.3)Apertatype: task
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
spring-projects/spring-data-rest#2623 ·
-
Release 5.2.0 (2026.1.0)Apertatype: task
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
spring-projects/spring-data-rest#2622 ·
-
Merge patch drops linkable associations of existing array elements since 4.3Forse già presa @odrotbohm l’ha presa 30 giorni fa. Apertastatus: feedback-provided status: waiting-for-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
spring-projects/spring-data-rest#2596 · 3 commenti · 1 assegnatario ·
-
Querydsl filtering silently ignores nested property paths since GH-2572Forse già presa @odrotbohm l’ha presa 30 giorni fa. Apertatype: regression
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
spring-projects/spring-data-rest#2579 · 1 reazione · 1 assegnatario ·
Tutte le issue di spring-projects/spring-data-rest
Issue simili
-
bug web-server
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jooby-project/jooby#4035 ·
I maintainer di solito rispondono entro 1 giorno
-
L: javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dependabot/dependabot-core#16744 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
quarkiverse/quarkus-google-cloud-services#1187 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
locationtech/jts#1250 ·
-
type/improve
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100