|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * Copyright Red Hat Inc. and Hibernate Authors |
| 4 | + */ |
| 5 | +package org.hibernate.orm.test.sql.partition; |
| 6 | + |
| 7 | +import jakarta.persistence.Entity; |
| 8 | +import jakarta.persistence.Id; |
| 9 | +import jakarta.persistence.Table; |
| 10 | +import org.hibernate.annotations.PartitionKey; |
| 11 | +import org.hibernate.dialect.SybaseASEDialect; |
| 12 | +import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; |
| 13 | +import org.hibernate.testing.orm.junit.FailureExpected; |
| 14 | +import org.hibernate.testing.orm.junit.Jpa; |
| 15 | +import org.hibernate.testing.orm.junit.RequiresDialect; |
| 16 | +import org.junit.jupiter.api.Test; |
| 17 | + |
| 18 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 19 | + |
| 20 | +// MUST RUN AS USER sa: |
| 21 | +// sp_configure 'enable semantic partitioning', 1 |
| 22 | +@RequiresDialect(SybaseASEDialect.class) |
| 23 | +@Jpa(annotatedClasses = SybasePartitionedTableTest.Partitioned.class) |
| 24 | +@FailureExpected(reason = "can't configure 'enable semantic partitioning'") |
| 25 | +class SybasePartitionedTableTest { |
| 26 | + @Test void test(EntityManagerFactoryScope scope) { |
| 27 | + scope.inTransaction( session -> { |
| 28 | + Partitioned partitioned = new Partitioned(); |
| 29 | + partitioned.id = 1L; |
| 30 | + partitioned.pid = 500L; |
| 31 | + session.persist( partitioned ); |
| 32 | + } ); |
| 33 | + scope.inTransaction( session -> { |
| 34 | + Partitioned partitioned = session.find( Partitioned.class, 1L ); |
| 35 | + assertNotNull( partitioned ); |
| 36 | + partitioned.text = "updated"; |
| 37 | + } ); |
| 38 | + } |
| 39 | + @Entity |
| 40 | + @Table(name = "syparts", |
| 41 | + options = |
| 42 | + """ |
| 43 | + PARTITION BY RANGE (pid) ( |
| 44 | + p1 VALUES <= (1000), |
| 45 | + p2 VALUES <= (2000) |
| 46 | + ) |
| 47 | + """) |
| 48 | + static class Partitioned { |
| 49 | + @Id Long id; |
| 50 | + @PartitionKey Long pid; |
| 51 | + String text = ""; |
| 52 | + } |
| 53 | +} |
0 commit comments