mirror of https://github.com/apache/openjpa.git
fix BigDecimal problem in the test case for MySQL
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@814085 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1aab5c3c6c
commit
60e55574c8
|
@ -22,6 +22,13 @@ import java.math.BigDecimal;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import junit.textui.TestRunner;
|
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;
|
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +38,7 @@ public class TestSQLBigDecimalId
|
||||||
extends SingleEMFTestCase {
|
extends SingleEMFTestCase {
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
setUp(SQLBigDecimalIdEntity.class, CLEAR_TABLES);
|
setUp(SQLBigDecimalIdEntity.class, DROP_TABLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPersist() {
|
public void testPersist() {
|
||||||
|
@ -42,6 +49,17 @@ public class TestSQLBigDecimalId
|
||||||
e.setId(decimal);
|
e.setId(decimal);
|
||||||
e.setData(1);
|
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();
|
EntityManager em = emf.createEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.persist(e);
|
em.persist(e);
|
||||||
|
|
Loading…
Reference in New Issue