diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index ff72cd5c8..903f3b66c 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -453,7 +453,7 @@ public class DBDictionary * @see #fractionalTypeNameSet * @see #getFractionLength(Column, String) */ - protected int defaultFractionLength = 6; + public int defaultFractionLength = 6; protected final Set typeModifierSet = new HashSet<>(); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java index 4443a5655..454288cc7 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java @@ -165,6 +165,8 @@ public class MariaDBDictionary extends DBDictionary { setTrailingDelimiter(DELIMITER_BACK_TICK); fixedSizeTypeNameSet.remove("NUMERIC"); + + defaultFractionLength = 0; } @Override diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java index f71425e35..256bd3637 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java @@ -166,6 +166,8 @@ public class MySQLDictionary setTrailingDelimiter(DELIMITER_BACK_TICK); fixedSizeTypeNameSet.remove("NUMERIC"); + + defaultFractionLength = 0; } @Override diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/TestExplicitAccess.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/TestExplicitAccess.java index f7f87b761..18787695f 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/TestExplicitAccess.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/TestExplicitAccess.java @@ -41,6 +41,7 @@ public class TestExplicitAccess extends SingleEMFTestCase { @Override public void setUp() { setUp(CLEAR_TABLES, + "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)", PropAccess.class, FieldAccess.class, DefFieldMixedPropAccess.class , DefPropMixedFieldAccess.class, AbstractMappedSuperField.class, PropertySub.class, diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/xml/TestXMLExplicitAccess.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/xml/TestXMLExplicitAccess.java index 7bc73dbac..8891028a7 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/xml/TestXMLExplicitAccess.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/access/xml/TestXMLExplicitAccess.java @@ -33,13 +33,10 @@ public class TestXMLExplicitAccess extends SingleEMFTestCase { @Override public void setUp() throws Exception { - super.setUp(); + super.setUp(CLEAR_TABLES, + "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)"); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } @Override protected String getPersistenceUnitName() { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java index 62e7c10eb..5495d3021 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java @@ -59,8 +59,10 @@ public class TestMany2ManyMapEx10 extends SQLListenerTestCase { @Override public void setUp() { - super.setUp(DROP_TABLES,EmployeePK.class, PhonePK.class, - Employee.class, PhoneNumber.class); + super.setUp(DROP_TABLES, + "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)", + EmployeePK.class, PhonePK.class, + Employee.class, PhoneNumber.class); createObj(); rsAllPhones = getAll(PhoneNumber.class); rsAllEmps = getAll(Employee.class); diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestHintedQuery.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestHintedQuery.java index 43ec1e71b..c1165db1a 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestHintedQuery.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestHintedQuery.java @@ -38,7 +38,9 @@ public class TestHintedQuery extends SQLListenerTestCase { @Override public void setUp() { - super.setUp(CLEAR_TABLES, TimeKeeper.class); + super.setUp(CLEAR_TABLES, + "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)", + TimeKeeper.class); } public void testHintedQuery() { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestTemporalTypeQueryParameterBinding.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestTemporalTypeQueryParameterBinding.java index e6108d968..a4f4c2a69 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestTemporalTypeQueryParameterBinding.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestTemporalTypeQueryParameterBinding.java @@ -63,7 +63,9 @@ public class TestTemporalTypeQueryParameterBinding extends SingleEMFTestCase { private EntityManager em; @Override public void setUp() throws Exception { - super.setUp(CLEAR_TABLES, TimeKeeper.class, TimeEntity.class); + super.setUp(CLEAR_TABLES, + "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)", + TimeKeeper.class, TimeEntity.class); em = emf.createEntityManager(); TimeKeeper pc = new TimeKeeper(); diff --git a/openjpa-project/src/doc/manual/supported_databases.xml b/openjpa-project/src/doc/manual/supported_databases.xml index d194276ee..2b130386b 100644 --- a/openjpa-project/src/doc/manual/supported_databases.xml +++ b/openjpa-project/src/doc/manual/supported_databases.xml @@ -1193,6 +1193,15 @@ The number of fractions can be explicitly set via scale: MariaDB + + + Example properties for MariaDB + + + openjpa.ConnectionDriverName: org.mariadb.jdbc.Driver + openjpa.ConnectionURL: jdbc:mariadb://SERVER_NAME/DB_NAME + +
Known issues with MariaDB @@ -1201,9 +1210,10 @@ The number of fractions can be explicitly set via scale: <listitem> <para> As of MariaDB 10.2 the <code>DATETIME</code> data type supports sub-second fractions. - The default of MariaDB is to use no fractions. + The default of MariaDB internally is to use no fractions. The number of fractions can be explicitly set via scale: - <code>@Column(scale=3)</code> will lead to a <code>DATETIME(3)</code> column. + <code>@Column(scale=6)</code> will lead to a <code>DATETIME(6)</code> column and able to store microseconds. + A value of <code>@Column(scale=-1)</code> will explicitly turn off all fractions. </para> </listitem>