OPENJPA-2555 use a defaultFractionLength of 0 for backward compat

This is how the default of MySQL and the previous behaviour of OpenJPA did.
If a user want he can use either @Column(scale=n) or set it via DBDictionary:
openjpa.jdbc.DBDictionary=(defaultFractionLength=6)
This commit is contained in:
Mark Struberg 2019-04-05 10:29:27 +02:00
parent a5b50a5bd4
commit 4e59c48364
9 changed files with 30 additions and 12 deletions

View File

@ -453,7 +453,7 @@ public class DBDictionary
* @see #fractionalTypeNameSet
* @see #getFractionLength(Column, String)
*/
protected int defaultFractionLength = 6;
public int defaultFractionLength = 6;
protected final Set<String> typeModifierSet = new HashSet<>();

View File

@ -165,6 +165,8 @@ public class MariaDBDictionary extends DBDictionary {
setTrailingDelimiter(DELIMITER_BACK_TICK);
fixedSizeTypeNameSet.remove("NUMERIC");
defaultFractionLength = 0;
}
@Override

View File

@ -166,6 +166,8 @@ public class MySQLDictionary
setTrailingDelimiter(DELIMITER_BACK_TICK);
fixedSizeTypeNameSet.remove("NUMERIC");
defaultFractionLength = 0;
}
@Override

View File

@ -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,

View File

@ -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() {

View File

@ -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);

View File

@ -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() {

View File

@ -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();

View File

@ -1193,6 +1193,15 @@ The number of fractions can be explicitly set via scale:
<title>
MariaDB
</title>
<example id="example_props_mariadb">
<title>
Example properties for MariaDB
</title>
<programlisting>
openjpa.ConnectionDriverName: org.mariadb.jdbc.Driver
openjpa.ConnectionURL: jdbc:mariadb://SERVER_NAME/DB_NAME
</programlisting>
</example>
<section id="dbsupport_mariadb_issues">
<title>
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>