-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18266 from famod/spring-data-jpa-fix-inheritance
Fix parse error on attribute from @Inheritance superclass in spring-data extension
- Loading branch information
Showing
10 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ation-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import javax.persistence.DiscriminatorColumn; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Inheritance; | ||
import javax.persistence.InheritanceType; | ||
|
||
@Entity | ||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||
@DiscriminatorColumn(name = "type") | ||
public class CatalogValue extends AbstractEntity { | ||
|
||
private String key; | ||
private String displayName; | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValueRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CatalogValueRepository extends JpaRepository<CatalogValue, Long> { | ||
|
||
CatalogValue findByKey(String key); | ||
} |
34 changes: 34 additions & 0 deletions
34
...sts/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValueResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
|
||
@Path("/catalog-value") | ||
public class CatalogValueResource { | ||
|
||
private final CatalogValueRepository repository; | ||
|
||
private final FederalStateCatalogValueRepository federalStateRepository; | ||
|
||
public CatalogValueResource(CatalogValueRepository repository, | ||
FederalStateCatalogValueRepository federalStateRepository) { | ||
this.repository = repository; | ||
this.federalStateRepository = federalStateRepository; | ||
} | ||
|
||
@Path("/super/{key}") | ||
@GET | ||
@Produces("application/json") | ||
public CatalogValue findByKey(@PathParam("key") String key) { | ||
return repository.findByKey(key); | ||
} | ||
|
||
@Path("/federal-state/{key}") | ||
@GET | ||
@Produces("application/json") | ||
public CatalogValue findFederalStateByKey(@PathParam("key") String key) { | ||
return federalStateRepository.findByKey(key); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/FederalStateCatalogValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@DiscriminatorValue("federalState") | ||
public class FederalStateCatalogValue extends CatalogValue { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...a-jpa/src/main/java/io/quarkus/it/spring/data/jpa/FederalStateCatalogValueRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FederalStateCatalogValueRepository extends JpaRepository<FederalStateCatalogValue, Long> { | ||
|
||
// note: key is defined in superclass of FederalStateCatalogValue | ||
FederalStateCatalogValue findByKey(String key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...s/spring-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/CatalogValueResourceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import io.quarkus.test.junit.NativeImageTest; | ||
|
||
@NativeImageTest | ||
public class CatalogValueResourceIT extends CatalogValueResourceTest { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...spring-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/CatalogValueResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class CatalogValueResourceTest { | ||
|
||
@Test | ||
void findByKey() { | ||
when().get("/catalog-value/super/DE-SN").then() | ||
.statusCode(200) | ||
.body(containsString("Saxony")) | ||
.body(containsString("DE-SN")); | ||
} | ||
|
||
@Test | ||
void findFederalStateByKey() { | ||
when().get("/catalog-value/federal-state/DE-SN").then() | ||
.statusCode(200) | ||
.body(containsString("Saxony")) | ||
.body(containsString("DE-SN")); | ||
} | ||
} |