Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 26233 invoked from network); 4 Aug 2009 01:58:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Aug 2009 01:58:32 -0000 Received: (qmail 38238 invoked by uid 500); 4 Aug 2009 01:58:37 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 38151 invoked by uid 500); 4 Aug 2009 01:58:37 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 38141 invoked by uid 99); 4 Aug 2009 01:58:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 01:58:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 01:58:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0DEB1234C045 for ; Mon, 3 Aug 2009 18:58:15 -0700 (PDT) Message-ID: <1801139957.1249351095052.JavaMail.jira@brutus> Date: Mon, 3 Aug 2009 18:58:15 -0700 (PDT) From: "Christopher Davies (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-1224) OpenJPA MySQL BigDecimal ignoring Precision/Scale column Annotation when generating tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org OpenJPA MySQL BigDecimal ignoring Precision/Scale column Annotation when generating tables ------------------------------------------------------------------------------------------- Key: OPENJPA-1224 URL: https://issues.apache.org/jira/browse/OPENJPA-1224 Project: OpenJPA Issue Type: Bug Components: jpa Affects Versions: 1.2.1 Environment: OpenJPA 1.2.1, MySQL 5.1.32 (InnoDB), Reporter: Christopher Davies Create an entity with a BigDecimal member. Using runtime enhancement and automatic schema generation. When OpneJPA creates the table it creates a column of type DECIMAL but will always ignore the precision set on the column annotation and use the default of (10,0) causing BigDecimal data to round up to the nearest whole number. Sample of basic Entity: @Entity public class Asset implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=SEQUENCE, generator="ASSET_SEQ") private String uniqueid; @Column(precision=10,scale=6,) private BigDecimal rate; public Asset() { this.rate = rate; } public void setRate(BigDecimal rate) { this.rate = rate; } public BigDecimal getRate() { return rate; } } Code to generate schema and save entity: Asset asset = new Asset(); asset.setRate(BigDecimal bd = new BigDecimal(100.004)); Now called persist/merge on the entity to generate the table schema and save the entity. The table is generated and the "rate" column is set to type DECIMAL(10,0) instead of DECIMAL(10,6). The table create script looks like this: DROP TABLE IF EXISTS `trm`.`asset`; CREATE TABLE `trm`.`asset` ( `uniqueid` varchar(255) NOT NULL, `rate` decimal(10,0) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=latin1; doubles work ok. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.