Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 9611 invoked from network); 31 Jul 2008 20:48:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Jul 2008 20:48:53 -0000 Received: (qmail 86045 invoked by uid 500); 31 Jul 2008 20:48:52 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 85986 invoked by uid 500); 31 Jul 2008 20:48:51 -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 85916 invoked by uid 99); 31 Jul 2008 20:48:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jul 2008 13:48:51 -0700 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; Thu, 31 Jul 2008 20:48:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AB29E234C18A for ; Thu, 31 Jul 2008 13:48:31 -0700 (PDT) Message-ID: <2112471448.1217537311700.JavaMail.jira@brutus> Date: Thu, 31 Jul 2008 13:48:31 -0700 (PDT) From: "Michael Dick (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-393) @Column(nullable=false) setting not taken into account for String field values In-Reply-To: <14457521.1191712191592.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael Dick updated OPENJPA-393: --------------------------------- Fix Version/s: 1.2.0 > @Column(nullable=false) setting not taken into account for String field values > ------------------------------------------------------------------------------ > > Key: OPENJPA-393 > URL: https://issues.apache.org/jira/browse/OPENJPA-393 > Project: OpenJPA > Issue Type: Bug > Affects Versions: 1.0.0 > Environment: Linux 2.6, Java JDK 1.5.0.11, Spring 2.0.7 > Reporter: Gergely Kis > Assignee: Pinaki Poddar > Fix For: 1.2.0 > > > The @Column(nullable=false) annotation is taken into account when creating the database schema, however it is not taken into account when inserting string values. > See the following test case: > @Entity > public class A { > @Id > private long id; > @Column(nullable=false) > private String name; > public A() {} > public A(String name) { this.name = name; } > [...accessor methods omitted...] > } > When trying to persist the instance A(null), the record will be created successfully with an empty string as the value of the name column, instead of returning an error. > According to my analysis the problem is the following. When the @Column annotations are parsed (see AnnotationPersistenceMappingParser) the FieldMapping.setNullValue() method is not called. As a result, when fetching the String field value for storing it in the database the default value for strings is returned (which is an empty string), instead of raising an exception. See StringFieldStrategy.toDataStoreValue() for reference. > The proposed solution would be to call this setNullValue method with the appropriate parameter while @Column annotations are parsed, but I don't know the OpenJPA source well enough to determine whether this is the proper fix or if there are other parameters that should be set in the FieldMapping. However, my local tests fixed the reported issue. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.