[openjpa] branch master updated (a5b50a5 -> dc31b80)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[openjpa] branch master updated (a5b50a5 -> dc31b80)

struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


    from a5b50a5  OPENJPA-2784 add docs for sub-second fractions in MariaDB and MySQL
     new 4e59c48  OPENJPA-2555 use a defaultFractionLength of 0 for backward compat
     new 64af851  fix random failing behaviour if id did already exist
     new dc31b80  OPENJPA-2555 fix randomly failing tests by forcing microseconds

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/openjpa/jdbc/sql/DBDictionary.java     |  2 +-
 .../org/apache/openjpa/jdbc/sql/MariaDBDictionary.java     |  2 ++
 .../java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java  |  2 ++
 .../openjpa/persistence/TestMixedMappingLocation.java      |  4 +++-
 .../openjpa/persistence/access/TestExplicitAccess.java     |  1 +
 .../persistence/access/xml/TestXMLExplicitAccess.java      |  7 ++-----
 .../jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java         |  6 ++++--
 .../openjpa/persistence/jdbc/query/TestHintedQuery.java    |  4 +++-
 .../jdbc/query/TestTemporalTypeQueryParameterBinding.java  |  4 +++-
 .../persistence/jpql/functions/TestSetParameter.java       |  9 ++++++++-
 .../openjpa/persistence/xml/TestSimpleXmlEntity.java       |  6 +++---
 .../openjpa/persistence/xml/TestXmlOverrideEntity.java     |  6 +++---
 openjpa-project/src/doc/manual/supported_databases.xml     | 14 ++++++++++++--
 13 files changed, 47 insertions(+), 20 deletions(-)

Reply | Threaded
Open this post in threaded view
|

[openjpa] 01/03: OPENJPA-2555 use a defaultFractionLength of 0 for backward compat

struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit 4e59c4836407382f853306dfd0ffbd14cba6e5c1
Author: Mark Struberg <[hidden email]>
AuthorDate: Fri Apr 5 10:29:27 2019 +0200

    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)
---
 .../java/org/apache/openjpa/jdbc/sql/DBDictionary.java     |  2 +-
 .../org/apache/openjpa/jdbc/sql/MariaDBDictionary.java     |  2 ++
 .../java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java  |  2 ++
 .../openjpa/persistence/access/TestExplicitAccess.java     |  1 +
 .../persistence/access/xml/TestXMLExplicitAccess.java      |  7 ++-----
 .../jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java         |  6 ++++--
 .../openjpa/persistence/jdbc/query/TestHintedQuery.java    |  4 +++-
 .../jdbc/query/TestTemporalTypeQueryParameterBinding.java  |  4 +++-
 openjpa-project/src/doc/manual/supported_databases.xml     | 14 ++++++++++++--
 9 files changed, 30 insertions(+), 12 deletions(-)

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 ff72cd5..903f3b6 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<String> 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 4443a56..454288c 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 f71425e..256bd36 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 f7f87b7..1878769 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 7bc73db..8891028 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 62e7c10..5495d30 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 43ec1e7..c1165db 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 e6108d9..a4f4c2a 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 d194276..2b13038 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:
         <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>
 

Reply | Threaded
Open this post in threaded view
|

[openjpa] 02/03: fix random failing behaviour if id did already exist

struberg
In reply to this post by struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit 64af85106ae52432c91ff6fa5bf0ed95323d457e
Author: Mark Struberg <[hidden email]>
AuthorDate: Fri Apr 5 11:07:53 2019 +0200

    fix random failing behaviour if id did already exist
---
 .../openjpa/persistence/jpql/functions/TestSetParameter.java     | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestSetParameter.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestSetParameter.java
index 40a142f..cb61095 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestSetParameter.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/functions/TestSetParameter.java
@@ -119,9 +119,16 @@ public class TestSetParameter extends SingleEMFTestCase {
     public void testNativeSQL() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+
+        // make sure that the ID we want to insert does not exist.
+        int proposedId;
+        do {
+            proposedId = (int) System.currentTimeMillis() % 10000;
+        } while (em.find(Address.class, proposedId) != null);
+
         int count = em.createNativeQuery("INSERT INTO Address (id, city,"
           + " country, streetAd, zipcode) VALUES (?,?,?,?,?)")
-          .setParameter(1, System.currentTimeMillis()%10000)
+          .setParameter(1, proposedId)
           .setParameter(2, "Some City")
           .setParameter(3, "Some Country")
           .setParameter(4, "Some Street")

Reply | Threaded
Open this post in threaded view
|

[openjpa] 03/03: OPENJPA-2555 fix randomly failing tests by forcing microseconds

struberg
In reply to this post by struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit dc31b800b8831d606c9621be2935282b666ecf64
Author: Mark Struberg <[hidden email]>
AuthorDate: Fri Apr 5 12:57:23 2019 +0200

    OPENJPA-2555 fix randomly failing tests by forcing microseconds
---
 .../org/apache/openjpa/persistence/TestMixedMappingLocation.java    | 4 +++-
 .../org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java     | 6 +++---
 .../org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java   | 6 +++---
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestMixedMappingLocation.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestMixedMappingLocation.java
index 5c00ac5..ea09d09 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestMixedMappingLocation.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/TestMixedMappingLocation.java
@@ -32,7 +32,9 @@ public class TestMixedMappingLocation extends SingleEMFTestCase {
 
     @Override
     public void setUp() {
-        setUp(DROP_TABLES,MixedMappingLocationEmbeddedId.class, MixedMappingLocation.class);
+        setUp(DROP_TABLES,
+                "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
+                MixedMappingLocationEmbeddedId.class, MixedMappingLocation.class);
     }
     /**
      * Testcase for added OPENJPA859.
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
index 163ee56..0016d57 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java
@@ -26,9 +26,9 @@ public class TestSimpleXmlEntity
 
     @Override
     public void setUp() {
-        setUp(
-        org.apache.openjpa.persistence.embed.attrOverrides.AnnoOverEmbed.class,
-        CLEAR_TABLES);
+        setUp(CLEAR_TABLES,
+                "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
+                org.apache.openjpa.persistence.embed.attrOverrides.AnnoOverEmbed.class);
     }
 
     @Override
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
index ebc6d48..9a8fcb7 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
@@ -35,9 +35,9 @@ public class TestXmlOverrideEntity extends SingleEMFTestCase {
 
     @Override
     public void setUp() throws ClassNotFoundException {
-        setUp(
-        org.apache.openjpa.persistence.embed.attrOverrides.AnnoOverEmbed.class,
-        CLEAR_TABLES);
+        setUp(CLEAR_TABLES,
+                "openjpa.jdbc.DBDictionary", "(defaultFractionLength=6)",
+                org.apache.openjpa.persistence.embed.attrOverrides.AnnoOverEmbed.class);
 
         // make sure that XmlOverrideEntity is registered for our metadata tests
         Class.forName(XmlOverrideEntity.class.getName(), true,