|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | + * Copyright Red Hat Inc. and Hibernate Authors |
| 4 | + */ |
| 5 | +package org.hibernate.community.dialect; |
| 6 | + |
| 7 | +import org.hibernate.testing.orm.junit.DomainModel; |
| 8 | +import org.hibernate.testing.orm.junit.JiraKey; |
| 9 | +import org.hibernate.testing.orm.junit.RequiresDialect; |
| 10 | +import org.hibernate.testing.orm.junit.SessionFactory; |
| 11 | +import org.hibernate.testing.orm.junit.SessionFactoryScope; |
| 12 | +import org.junit.jupiter.api.AfterEach; |
| 13 | +import org.junit.jupiter.api.BeforeEach; |
| 14 | +import org.junit.jupiter.api.Test; |
| 15 | + |
| 16 | +import jakarta.persistence.Entity; |
| 17 | +import jakarta.persistence.Id; |
| 18 | + |
| 19 | +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
| 20 | + |
| 21 | +@RequiresDialect(SybaseAnywhereDialect.class) |
| 22 | +@DomainModel(annotatedClasses = SybaseAnywhereTest.MyEntity.class) |
| 23 | +@SessionFactory |
| 24 | +@JiraKey("HHH-18471") |
| 25 | +public class SybaseAnywhereTest { |
| 26 | + |
| 27 | + @BeforeEach |
| 28 | + public void setUp(SessionFactoryScope scope) { |
| 29 | + scope.inTransaction( |
| 30 | + session -> { |
| 31 | + session.persist( new MyEntity( 1l, "test" ) ); |
| 32 | + } |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + @AfterEach |
| 37 | + public void tearDown(SessionFactoryScope scope) { |
| 38 | + scope.inTransaction( |
| 39 | + session -> { |
| 40 | + session.createMutationQuery( "delete from MyEntity" ).executeUpdate(); |
| 41 | + } |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void testFind(SessionFactoryScope scope) { |
| 47 | + scope.inTransaction( |
| 48 | + session -> { |
| 49 | + MyEntity myEntity = session.find( MyEntity.class, 1l ); |
| 50 | + assertThat( myEntity ).isNotNull(); |
| 51 | + } |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + @Entity(name = "MyEntity") |
| 56 | + public static class MyEntity { |
| 57 | + @Id |
| 58 | + private Long id; |
| 59 | + |
| 60 | + private String name; |
| 61 | + |
| 62 | + public MyEntity() { |
| 63 | + } |
| 64 | + |
| 65 | + public MyEntity(Long id, String name) { |
| 66 | + this.id = id; |
| 67 | + this.name = name; |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments