-
Notifications
You must be signed in to change notification settings - Fork 99
Error when inserting in batch with joined table inheritance #2163
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
130 changes: 130 additions & 0 deletions
130
hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedInheritanceBatchTest.java
This file contains hidden or 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,130 @@ | ||
/* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.reactive; | ||
|
||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.vertx.junit5.Timeout; | ||
import io.vertx.junit5.VertxTestContext; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Inheritance; | ||
import jakarta.persistence.InheritanceType; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
import static java.util.concurrent.TimeUnit.MINUTES; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; | ||
|
||
@Timeout(value = 10, timeUnit = MINUTES) | ||
public class JoinedInheritanceBatchTest extends BaseReactiveTest { | ||
|
||
@Override | ||
protected Collection<Class<?>> annotatedEntities() { | ||
return List.of( ClientA.class, Client.class ); | ||
} | ||
|
||
@Override | ||
protected CompletionStage<Void> cleanDb() { | ||
return voidFuture(); | ||
} | ||
|
||
@Test | ||
public void test(VertxTestContext context) { | ||
final ClientA client1 = new ClientA("Client 1", "email@c1", "123456"); | ||
|
||
test( context, getMutinySessionFactory().withTransaction( session -> { | ||
session.setBatchSize( 5 ); | ||
return session.persist( client1 ); | ||
} ) | ||
.chain( () -> getMutinySessionFactory().withTransaction( session -> session | ||
.createQuery( "select c from Client c", Client.class ) | ||
.getResultList() | ||
.invoke( persistedClients -> assertThat( persistedClients ) | ||
.as( "Clients has not bee persisted" ) | ||
.isNotEmpty() ) ) ) | ||
); | ||
} | ||
|
||
@Entity(name = "Client") | ||
@Table(name = "`Client`") | ||
@Inheritance(strategy = InheritanceType.JOINED) | ||
public static class Client { | ||
|
||
@Id | ||
@SequenceGenerator(name = "seq", sequenceName = "id_seq", allocationSize = 1) | ||
@GeneratedValue(generator = "seq", strategy = GenerationType.SEQUENCE) | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String email; | ||
|
||
private String phone; | ||
|
||
public Client() { | ||
} | ||
|
||
public Client(String name, String email, String phone) { | ||
this.name = name; | ||
this.email = email; | ||
this.phone = phone; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
|
||
} | ||
|
||
@Entity | ||
@Table(name = "`ClientA`") | ||
public static class ClientA extends Client { | ||
|
||
public ClientA() { | ||
} | ||
|
||
public ClientA(String name, String email, String phone) { | ||
super( name, email, phone ); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.