-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Spring Data Repository with nested camel-case properties does not…
… work with Quarkus #13067
- Loading branch information
Showing
8 changed files
with
275 additions
and
158 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
269 changes: 111 additions & 158 deletions
269
...data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java
Large diffs are not rendered by default.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/Employee.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,69 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
// TODO: @Entity(name = "EmployeeEntity") | ||
@Entity | ||
@Table(name = "org_employee_table") | ||
public class Employee extends AbstractEntity { | ||
|
||
@Column(name = "user_id") | ||
private String userId; | ||
|
||
@Column(name = "first_name") | ||
private String firstName; | ||
|
||
@Column(name = "last_name") | ||
private String lastName; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "team_id", nullable = false) | ||
private Team belongsToTeam; | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public Team getBelongsToTeam() { | ||
return belongsToTeam; | ||
} | ||
|
||
@Entity // TODO: (name = "UserRoleEntity") | ||
@Table(name = "org_team_table") | ||
public static class Team extends AbstractEntity { | ||
|
||
private String name; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "unit_id", nullable = false) | ||
private OrgUnit organizationalUnit; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public OrgUnit getOrganizationalUnit() { | ||
return organizationalUnit; | ||
} | ||
} | ||
|
||
@Entity // TODO: (name = "OrgUnitEntity") | ||
@Table(name = "org_unit_table") | ||
public static class OrgUnit extends AbstractEntity { | ||
|
||
private String name; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/EmployeeRepository.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 java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface EmployeeRepository extends JpaRepository<Employee, Long> { | ||
|
||
List<Employee> findByBelongsToTeamOrganizationalUnitsName(String orgUnitName); | ||
} |
36 changes: 36 additions & 0 deletions
36
...n-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/EmployeeResource.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,36 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import java.util.List; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
|
||
@Path("/employee") | ||
@Produces("application/json") | ||
public class EmployeeResource { | ||
|
||
private final EmployeeRepository employeeRepository; | ||
|
||
public EmployeeResource(EmployeeRepository employeeRepository) { | ||
this.employeeRepository = employeeRepository; | ||
} | ||
|
||
@GET | ||
public List<Employee> findAll() { | ||
return this.employeeRepository.findAll(); | ||
} | ||
|
||
@GET | ||
@Path("/{id}") | ||
public Employee findById(@PathParam("id") Long id) { | ||
return this.employeeRepository.findById(id).orElse(null); | ||
} | ||
|
||
@GET | ||
@Path("/unit/{orgUnitName}") | ||
public List<Employee> findByManagerOfManager(@PathParam("orgUnitName") String orgUnitName) { | ||
return this.employeeRepository.findByBelongsToTeamOrganizationalUnitsName(orgUnitName); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...tests/spring-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/EmployeeResourceIT.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,7 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import io.quarkus.test.junit.NativeImageTest; | ||
|
||
@NativeImageTest | ||
public class EmployeeResourceIT extends EmployeeResourceTest { | ||
} |
24 changes: 24 additions & 0 deletions
24
...sts/spring-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/EmployeeResourceTest.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,24 @@ | ||
package io.quarkus.it.spring.data.jpa; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class EmployeeResourceTest { | ||
|
||
@Test | ||
public void testFindEmployeesByOrganizationalUnit() { | ||
List<Employee> employees = when().get("/employee/unit/Delivery Unit").then() | ||
.statusCode(200) | ||
.extract().body().jsonPath().getList(".", Employee.class); | ||
|
||
assertThat(employees).extracting("userId").containsExactlyInAnyOrder("johdoe", "petdig"); | ||
} | ||
|
||
} |