Skip to content

Commit

Permalink
Do not (incorrectly) set the value of @GeneratedValue IDs in tests
Browse files Browse the repository at this point in the history
It causes failures on ORM 6.6, because that's forbidden.
Previous behavior is unclear but at the very least wasn't clearly
defined.

See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/EntityManager.2Emerge/near/447248421
  • Loading branch information
yrodiere committed Jun 27, 2024
1 parent 2df8f81 commit 4f4a04c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

Expand All @@ -24,7 +22,6 @@ public class Group {
private String value;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "groupSeq")
public Long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public <T extends Entity> Multi<T> stream() {
return (Multi<T>) results.toMulti().flatMap(list -> {
return Multi.createFrom().iterable(list);
});
}git s
}

@SuppressWarnings("unchecked")
public <T extends Entity> Uni<T> firstResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void shouldCreateHal() {
void shouldCreateAndUpdate() {
Response createResponse = given().accept("application/json")
.and().contentType("application/json")
.and().body("{\"id\": \"101\", \"name\": \"test-update-create\"}")
.and().body("{\"name\": \"test-update-create\"}")
.when().put("/crud-and-paged-records/101")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);
Expand Down Expand Up @@ -370,7 +370,7 @@ void shouldCreateAndUpdate() {
void shouldCreateAndUpdateHal() {
Response createResponse = given().accept("application/hal+json")
.and().contentType("application/json")
.and().body("{\"id\": \"102\", \"name\": \"test-update-create-hal\"}")
.and().body("{\"name\": \"test-update-create-hal\"}")
.when().put("/crud-and-paged-records/102")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ void shouldCreateHal() {
void shouldCreateAndUpdate() {
Response createResponse = given().accept("application/json")
.and().contentType("application/json")
.and().body("{\"id\": \"101\", \"name\": \"test-update-create\"}")
.when().put("/jpa-records/101")
.and().body("{\"name\": \"test-update-create\"}")
.when().post("/jpa-records/")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);

Expand All @@ -370,8 +370,8 @@ void shouldCreateAndUpdate() {
void shouldCreateAndUpdateHal() {
Response createResponse = given().accept("application/hal+json")
.and().contentType("application/json")
.and().body("{\"id\": \"102\", \"name\": \"test-update-create-hal\"}")
.when().put("/jpa-records/102")
.and().body("{\"name\": \"test-update-create-hal\"}")
.when().post("/jpa-records/")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void shouldCreateHal() {
void shouldCreateAndUpdate() {
Response createResponse = given().accept("application/json")
.and().contentType("application/json")
.and().body("{\"id\": \"101\", \"name\": \"test-update-create\"}")
.and().body("{\"name\": \"test-update-create\"}")
.when().put("/default-records/101")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);
Expand Down Expand Up @@ -177,7 +177,7 @@ void shouldCreateAndUpdate() {
void shouldCreateAndUpdateHal() {
Response createResponse = given().accept("application/hal+json")
.and().contentType("application/json")
.and().body("{\"id\": \"102\", \"name\": \"test-update-create-hal\"}")
.and().body("{\"name\": \"test-update-create-hal\"}")
.when().put("/default-records/102")
.thenReturn();
assertThat(createResponse.statusCode()).isEqualTo(201);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void shouldCreateUpdateAndDeleteBook() {
Response response = given().accept("application/json")
.and().contentType("application/json")
.and().body(book.toString())
.when().put("/books/100")
.when().post("/books/")
.thenReturn();
assertThat(response.statusCode()).isEqualTo(201);
assertThat(response.header("Location")).isNotEmpty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package io.quarkus.it.spring.data.jpa.complex;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Parent extends ParentBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

public Parent(Long id, String name, String detail, int age, float test, TestEnum testEnum) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package io.quarkus.it.spring.data.jpa.complex;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Parent2 extends ParentBase {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

public Parent2(String name, String detail, int age, float test, TestEnum testEnum, Long id) {
Expand Down

0 comments on commit 4f4a04c

Please sign in to comment.