mirror of https://github.com/apache/openjpa.git
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:
parent
a5b50a5bd4
commit
4e59c48364
|
@ -453,7 +453,7 @@ public class DBDictionary
|
||||||
* @see #fractionalTypeNameSet
|
* @see #fractionalTypeNameSet
|
||||||
* @see #getFractionLength(Column, String)
|
* @see #getFractionLength(Column, String)
|
||||||
*/
|
*/
|
||||||
protected int defaultFractionLength = 6;
|
public int defaultFractionLength = 6;
|
||||||
|
|
||||||
|
|
||||||
protected final Set<String> typeModifierSet = new HashSet<>();
|
protected final Set<String> typeModifierSet = new HashSet<>();
|
||||||
|
|
|
@ -165,6 +165,8 @@ public class MariaDBDictionary extends DBDictionary {
|
||||||
setTrailingDelimiter(DELIMITER_BACK_TICK);
|
setTrailingDelimiter(DELIMITER_BACK_TICK);
|
||||||
|
|
||||||
fixedSizeTypeNameSet.remove("NUMERIC");
|
fixedSizeTypeNameSet.remove("NUMERIC");
|
||||||
|
|
||||||
|
defaultFractionLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -166,6 +166,8 @@ public class MySQLDictionary
|
||||||
setTrailingDelimiter(DELIMITER_BACK_TICK);
|
setTrailingDelimiter(DELIMITER_BACK_TICK);
|
||||||
|
|
||||||
fixedSizeTypeNameSet.remove("NUMERIC");
|
fixedSizeTypeNameSet.remove("NUMERIC");
|
||||||
|
|
||||||
|
defaultFractionLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class TestExplicitAccess extends SingleEMFTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
setUp(CLEAR_TABLES,
|
setUp(CLEAR_TABLES,
|
||||||
|
"openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
|
||||||
PropAccess.class, FieldAccess.class,
|
PropAccess.class, FieldAccess.class,
|
||||||
DefFieldMixedPropAccess.class , DefPropMixedFieldAccess.class,
|
DefFieldMixedPropAccess.class , DefPropMixedFieldAccess.class,
|
||||||
AbstractMappedSuperField.class, PropertySub.class,
|
AbstractMappedSuperField.class, PropertySub.class,
|
||||||
|
|
|
@ -33,13 +33,10 @@ public class TestXMLExplicitAccess extends SingleEMFTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
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
|
@Override
|
||||||
protected String getPersistenceUnitName() {
|
protected String getPersistenceUnitName() {
|
||||||
|
|
|
@ -59,8 +59,10 @@ public class TestMany2ManyMapEx10 extends SQLListenerTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
super.setUp(DROP_TABLES,EmployeePK.class, PhonePK.class,
|
super.setUp(DROP_TABLES,
|
||||||
Employee.class, PhoneNumber.class);
|
"openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
|
||||||
|
EmployeePK.class, PhonePK.class,
|
||||||
|
Employee.class, PhoneNumber.class);
|
||||||
createObj();
|
createObj();
|
||||||
rsAllPhones = getAll(PhoneNumber.class);
|
rsAllPhones = getAll(PhoneNumber.class);
|
||||||
rsAllEmps = getAll(Employee.class);
|
rsAllEmps = getAll(Employee.class);
|
||||||
|
|
|
@ -38,7 +38,9 @@ public class TestHintedQuery extends SQLListenerTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
super.setUp(CLEAR_TABLES, TimeKeeper.class);
|
super.setUp(CLEAR_TABLES,
|
||||||
|
"openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
|
||||||
|
TimeKeeper.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHintedQuery() {
|
public void testHintedQuery() {
|
||||||
|
|
|
@ -63,7 +63,9 @@ public class TestTemporalTypeQueryParameterBinding extends SingleEMFTestCase {
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
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();
|
em = emf.createEntityManager();
|
||||||
|
|
||||||
TimeKeeper pc = new TimeKeeper();
|
TimeKeeper pc = new TimeKeeper();
|
||||||
|
|
|
@ -1193,6 +1193,15 @@ The number of fractions can be explicitly set via scale:
|
||||||
<title>
|
<title>
|
||||||
MariaDB
|
MariaDB
|
||||||
</title>
|
</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">
|
<section id="dbsupport_mariadb_issues">
|
||||||
<title>
|
<title>
|
||||||
Known issues with MariaDB
|
Known issues with MariaDB
|
||||||
|
@ -1201,9 +1210,10 @@ The number of fractions can be explicitly set via scale:
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
As of MariaDB 10.2 the <code>DATETIME</code> data type supports sub-second fractions.
|
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:
|
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>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue