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:
Fay Wang 2009-09-11 23:41:34 +00:00
parent 1aab5c3c6c
commit 60e55574c8
1 changed files with 19 additions and 1 deletions

View File

@ -22,6 +22,13 @@ import java.math.BigDecimal;
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 @@ public class TestSQLBigDecimalId
extends SingleEMFTestCase {
public void setUp() {
setUp(SQLBigDecimalIdEntity.class, CLEAR_TABLES);
setUp(SQLBigDecimalIdEntity.class, DROP_TABLES);
}
public void testPersist() {
@ -42,6 +49,17 @@ public class TestSQLBigDecimalId
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);