Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Types;

import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.boot.model.TypeContributions;
Expand Down Expand Up @@ -313,4 +314,11 @@ public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, D
public String getDual() {
return "dual";
}

@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return typeCode1 == Types.LONGVARCHAR && typeCode2 == SqlTypes.JSON
|| typeCode1 == SqlTypes.JSON && typeCode2 == Types.LONGVARCHAR
|| super.equivalentTypes( typeCode1, typeCode2 );
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading