From de8a565293a368c02ba3c3cbd58d3bcc833759bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cedomir=20Igaly?= Date: Wed, 4 Dec 2024 11:34:46 +0100 Subject: [PATCH] HHH-18869 Test case for Jira issue https://hibernate.atlassian.net/browse/HHH-18869 --- .../MariaDbJsonColumnValidationTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/MariaDbJsonColumnValidationTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/MariaDbJsonColumnValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/MariaDbJsonColumnValidationTest.java new file mode 100644 index 0000000000..aedfb618b4 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/MariaDbJsonColumnValidationTest.java @@ -0,0 +1,62 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.orm.test.schemavalidation; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; +import org.hibernate.testing.orm.junit.JiraKey; +import org.hibernate.testing.orm.junit.RequiresDialect; +import org.hibernate.tool.hbm2ddl.SchemaValidator; +import org.junit.Before; +import org.junit.Test; + +import java.math.BigDecimal; + +@JiraKey(value = "HHH-18869") +@RequiresDialect(value = MariaDBDialect.class) +public class MariaDbJsonColumnValidationTest extends BaseNonConfigCoreFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] {Foo.class}; + } + + @Before + public void init() { + try { + inTransaction( session -> { + try { + session.createNativeMutationQuery( "drop table Foo" ).executeUpdate(); + } + catch (Exception e) { + throw new RuntimeException( e ); + } + } + ); + inTransaction( session -> + session.createNativeMutationQuery( + "create table Foo (id integer not null, bigDecimals json, primary key (id)) engine=InnoDB" + ).executeUpdate() + ); + } + catch (Exception ignored) { + } + } + + @Test + public void testSchemaValidation() { + new SchemaValidator().validate( metadata() ); + } + + @Entity(name = "Foo") + @Table(name = "Foo") + public static class Foo { + @Id + public Integer id; + public BigDecimal[] bigDecimals; + } +}