hibernate-reactive icon indicating copy to clipboard operation
hibernate-reactive copied to clipboard

Implement ReactiveInsertExecutionDelegate.reactiveExecute() method

Open dreab8 opened this issue 10 months ago • 0 comments

Given

@Entity(name = "Person")
@Inheritance(strategy = InheritanceType.JOINED)
public static class Person {

	@Id
	private Long id;

	private String name;

	private boolean employed;

	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 boolean isEmployed() {
		return employed;
	}

	public void setEmployed(boolean employed) {
		this.employed = employed;
	}
}

@Entity(name = "Doctor")
public static class Doctor extends Person {
}

@Entity(name = "Engineer")
public static class Engineer extends Person {

	private boolean fellow;

	public boolean isFellow() {
		return fellow;
	}

	public void setFellow(boolean fellow) {
		this.fellow = fellow;
	}
}

when using GlobalTemporaryTableStrategy the test

@Test
public void testMultiTableInsert(VertxTestContext context) {
	test( context, getSessionFactory()
			.withSession( session -> session
					.createMutationQuery("insert into Engineer ( id, name,fellow, employed ) values ( :id, :name, :fellow, :employed )" )
					.setParameter( "id", 1L )
					.setParameter( "name", "John" )
					.setParameter( "fellow", true )
					.setParameter( "employed", true )
					.executeUpdate()
			)
			.thenCompose( i -> openSession())
			.thenCompose( session -> session.createQuery( "select e from Engineer e", Engineer.class ).getResultList() )
			.thenApply( engineers -> assertThat( engineers.size() ).isEqualTo( 1 ) )
	);
}

fails with

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletionStage.toCompletableFuture()" because the return value of "java.util.function.Function.apply(Object)" is null

because ReactiveInsertExecutionDelegate.reactiveExecute() is not implemented and returns null

dreab8 avatar Feb 13 '25 09:02 dreab8