|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | + * Copyright Red Hat Inc. and Hibernate Authors |
| 4 | + */ |
| 5 | +package org.hibernate.event.jfr.flush; |
| 6 | + |
| 7 | +import org.hibernate.testing.orm.junit.DomainModel; |
| 8 | +import org.hibernate.testing.orm.junit.JiraKey; |
| 9 | +import org.hibernate.testing.orm.junit.SessionFactory; |
| 10 | +import org.hibernate.testing.orm.junit.SessionFactoryScope; |
| 11 | +import org.junit.jupiter.api.Test; |
| 12 | + |
| 13 | +import jakarta.persistence.Entity; |
| 14 | +import jakarta.persistence.Id; |
| 15 | + |
| 16 | + |
| 17 | +@DomainModel(annotatedClasses = { |
| 18 | + AutoFlushJfrDisabledTests.TestEntity.class, |
| 19 | +}) |
| 20 | +@SessionFactory |
| 21 | +@JiraKey(value = "HHH-18770") |
| 22 | +public class AutoFlushJfrDisabledTests { |
| 23 | + |
| 24 | + /** |
| 25 | + * Execute a query (and a flush) with the jfr module on the classpath but jfr disabled |
| 26 | + */ |
| 27 | + @Test |
| 28 | + public void testFlushEventWithPartialFlushEventDisabled(SessionFactoryScope scope) { |
| 29 | + scope.inTransaction( |
| 30 | + session -> { |
| 31 | + TestEntity entity = new TestEntity( 1, "name_1" ); |
| 32 | + session.persist( entity ); |
| 33 | + session.createQuery( "select t from TestEntity t" ).list(); |
| 34 | + |
| 35 | + session.remove( entity ); |
| 36 | + } |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + @Entity(name = "TestEntity") |
| 41 | + public static class TestEntity { |
| 42 | + @Id |
| 43 | + private Integer id; |
| 44 | + |
| 45 | + private String name; |
| 46 | + |
| 47 | + public TestEntity() { |
| 48 | + } |
| 49 | + |
| 50 | + public TestEntity(Integer id, String name) { |
| 51 | + this.id = id; |
| 52 | + this.name = name; |
| 53 | + } |
| 54 | + |
| 55 | + public void setName(String name) { |
| 56 | + this.name = name; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments