Skip to content

PostgreSQL: Mutation query with Joined Inheritance for databases supporting Global Temporary issue with transactions #2412

@dreab8

Description

@dreab8

A test for this issue already exists here (at the moment, it's disabled for Postgres):

@DisabledFor( value = POSTGRESQL, reason = "vertx-sql-client issue: https://github.com/eclipse-vertx/vertx-sql-client/issues/1540" )

Given

@Entity(name="SpellBook")
	@Table(name = "SpellBookJS")
	@DiscriminatorValue("S")
	public static class SpellBook extends Book {

		private boolean forbidden;
	}

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

		@Id private Integer id;
		private String title;
		@Temporal(TemporalType.DATE)
		private Date published;
	
	}

the test

public void testHqlInsertWithTransaction(VertxTestContext context) {
		Integer id = 1;
		String title = "Spell Book: A Comprehensive Guide to Magic Spells and Incantations";
		test( context, getMutinySessionFactory()
				.withTransaction( session -> session.createMutationQuery( "insert into SpellBook (id, title, forbidden) values (:id, :title, :forbidden)" )
						.setParameter( "id", id )
						.setParameter( "title", title )
						.setParameter( "forbidden", true )
						.executeUpdate()
				).call( () -> getMutinySessionFactory()
						.withTransaction( session -> session.createSelectionQuery( "from SpellBook g where g.id = :id ", SpellBook.class )
								.setParameter( "id", id )
								.getSingleResult()
								.invoke( spellBook -> {
											 assertThat( spellBook.getTitle() ).isEqualTo( title );
											 assertThat( spellBook.forbidden ).isTrue();
										 }
								)
						)
				)
		);
	}

fails with

error executing SQL statement [ERROR: current transaction is aborted, commands ignored until end of transaction block (25P02)] [with HTE_SpellBookJS (id,title,forbidden) as materialized (select sb1_0.id,sb1_0.title,sb1_0.forbidden from (values ($1,$2,$3)) sb1_0(id,title,forbidden)),dml_cte_BookJS (id) as (insert into BookJS as sb1_1(id,title) select e.id,e.title from HTE_SpellBookJS e returning id),dml_cte_SpellBookJS (id) as (insert into SpellBookJS as sb1_0(id,forbidden) select e.id,e.forbidden from HTE_SpellBookJS e returning id) select count(*) from dml_cte_BookJS id]

The issue seems related to a Vert.x SQL driver issue eclipse-vertx/vertx-sql-client#1540

This issue is a follow-up of #2398

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions