mirror of https://github.com/apache/openjpa.git
OPENJPA-1224: Updating DBDictionaries to support setting precision on a BigDecimal column.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@890486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6cee09c8c9
commit
3067245dac
|
@ -29,7 +29,10 @@ public abstract class AbstractDB2Dictionary
|
|||
public int varcharCastLength = 1000;
|
||||
|
||||
public AbstractDB2Dictionary() {
|
||||
numericTypeName = "DOUBLE";
|
||||
// http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.java.doc
|
||||
// /doc/rjvjdata.htm
|
||||
// http://db.apache.org/derby/docs/10.3/ref/rrefsqlj12362.html
|
||||
numericTypeName = "DECIMAL";
|
||||
bitTypeName = "SMALLINT";
|
||||
smallintTypeName = "SMALLINT";
|
||||
tinyintTypeName = "SMALLINT";
|
||||
|
@ -69,6 +72,9 @@ public abstract class AbstractDB2Dictionary
|
|||
// the equivalent "X JOIN Y ON 1 = 1"
|
||||
crossJoinClause = "JOIN";
|
||||
requiresConditionForCrossJoin = true;
|
||||
|
||||
// DB2 / Derby allows precision to be set on a DECIMAL column.
|
||||
fixedSizeTypeNameSet.remove("DECIMAL");
|
||||
}
|
||||
|
||||
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
|
||||
|
|
|
@ -145,6 +145,8 @@ public class MySQLDictionary
|
|||
"ZEROFILL" }));
|
||||
|
||||
delimiter = "`";
|
||||
|
||||
fixedSizeTypeNameSet.remove("NUMERIC");
|
||||
}
|
||||
|
||||
public void connectedConfiguration(Connection conn) throws SQLException {
|
||||
|
|
|
@ -24,10 +24,6 @@ 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.test.AllowFailure;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
||||
/**
|
||||
|
@ -48,18 +44,6 @@ 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);
|
||||
|
@ -74,7 +58,6 @@ public class TestSQLBigDecimalId
|
|||
|
||||
}
|
||||
|
||||
@AllowFailure
|
||||
public void testQuery() {
|
||||
int data = 156;
|
||||
BigDecimal decimal = new BigDecimal(1234);
|
||||
|
@ -91,6 +74,7 @@ public class TestSQLBigDecimalId
|
|||
(SQLBigDecimalIdEntity) em.createQuery("SELECT a FROM SQLBigDecimalIdEntity a WHERE a.data=" + data)
|
||||
.getSingleResult();
|
||||
|
||||
// This would fail prior to OPENJPA-1224.
|
||||
assertEquals(e, e2);
|
||||
em.close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue