Skip to content

MariaDB, mutation delete query does not delete an entity with joined inheritance #2737

@dreab8

Description

@dreab8

Given:

@Entity
@DiscriminatorValue("S")
public static class SpellBook extends Book {

private boolean forbidden;
}

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public static class Book {

	@Id 
        private Integer id;
	private String title;
}

the following test fails

@Test
public void testHqlDelete(VertxTestContext context) {
	final Integer id = 1;
	final 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
					.createMutationQuery(
							"delete from SpellBook where id = :id and forbidden = :forbidden and title = :title" )
					.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 )
					.getSingleResultOrNull()
					.invoke( Assertions::assertNull ) )
			)
	);
}

Because the SpellBook is not deleted.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions