You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by fa...@apache.org on 2009/09/12 01:41:34 UTC
svn commit: r814085 -
/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
Author: faywang
Date: Fri Sep 11 23:41:34 2009
New Revision: 814085
URL: http://svn.apache.org/viewvc?rev=814085&view=rev
Log:
fix BigDecimal problem in the test case for MySQL
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java?rev=814085&r1=814084&r2=814085&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java Fri Sep 11 23:41:34 2009
@@ -22,6 +22,13 @@
import javax.persistence.EntityManager;
import junit.textui.TestRunner;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.MySQLDictionary;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
/**
@@ -31,7 +38,7 @@
extends SingleEMFTestCase {
public void setUp() {
- setUp(SQLBigDecimalIdEntity.class, CLEAR_TABLES);
+ setUp(SQLBigDecimalIdEntity.class, DROP_TABLES);
}
public void testPersist() {
@@ -42,6 +49,17 @@
e.setId(decimal);
e.setData(1);
+ // trigger schema definition
+ JDBCConfiguration jdbccfg = (JDBCConfiguration)emf.getConfiguration();
+ DBDictionary dict = jdbccfg.getDBDictionaryInstance();
+ //currently BigDecimal is mapped to NUMERIC column type. This causes
+ //truncation error from MySQL. Without knowing the implication of changing the
+ //mapping of BigDecimal universally to DOUBLE, I will just change the mapping
+ //for this test case.
+ if (dict instanceof MySQLDictionary) {
+ dict.numericTypeName = "DOUBLE";
+ }
+
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(e);