openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <>
Subject [jira] Assigned: (OPENJPA-393) @Column(nullable=false) setting not taken into account for String field values
Date Tue, 29 Jul 2008 18:43:32 GMT


Pinaki Poddar reassigned OPENJPA-393:

    Assignee: Pinaki Poddar

> @Column(nullable=false) setting not taken into account for String field values
> ------------------------------------------------------------------------------
>                 Key: OPENJPA-393
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>         Environment: Linux 2.6, Java JDK, Spring 2.0.7
>            Reporter: Gergely Kis
>            Assignee: Pinaki Poddar
> 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) { = 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.

View raw message