Skip to content

Commit de8a565

Browse files
cigalybeikov
authored andcommitted
HHH-18869 Test case for Jira issue https://hibernate.atlassian.net/browse/HHH-18869
1 parent efb62c7 commit de8a565

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.schemavalidation;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.Id;
9+
import jakarta.persistence.Table;
10+
import org.hibernate.dialect.MariaDBDialect;
11+
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
12+
import org.hibernate.testing.orm.junit.JiraKey;
13+
import org.hibernate.testing.orm.junit.RequiresDialect;
14+
import org.hibernate.tool.hbm2ddl.SchemaValidator;
15+
import org.junit.Before;
16+
import org.junit.Test;
17+
18+
import java.math.BigDecimal;
19+
20+
@JiraKey(value = "HHH-18869")
21+
@RequiresDialect(value = MariaDBDialect.class)
22+
public class MariaDbJsonColumnValidationTest extends BaseNonConfigCoreFunctionalTestCase {
23+
@Override
24+
protected Class<?>[] getAnnotatedClasses() {
25+
return new Class[] {Foo.class};
26+
}
27+
28+
@Before
29+
public void init() {
30+
try {
31+
inTransaction( session -> {
32+
try {
33+
session.createNativeMutationQuery( "drop table Foo" ).executeUpdate();
34+
}
35+
catch (Exception e) {
36+
throw new RuntimeException( e );
37+
}
38+
}
39+
);
40+
inTransaction( session ->
41+
session.createNativeMutationQuery(
42+
"create table Foo (id integer not null, bigDecimals json, primary key (id)) engine=InnoDB"
43+
).executeUpdate()
44+
);
45+
}
46+
catch (Exception ignored) {
47+
}
48+
}
49+
50+
@Test
51+
public void testSchemaValidation() {
52+
new SchemaValidator().validate( metadata() );
53+
}
54+
55+
@Entity(name = "Foo")
56+
@Table(name = "Foo")
57+
public static class Foo {
58+
@Id
59+
public Integer id;
60+
public BigDecimal[] bigDecimals;
61+
}
62+
}

0 commit comments

Comments
 (0)