openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (OPENJPA-2382) Wrong handling of char property
Date Thu, 16 May 2013 20:17:17 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-2382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kevin Sutter resolved OPENJPA-2382.
-----------------------------------

    Resolution: Not A Problem

By default, OpenJPA stores char data as numbers.  Generally, it's more efficient processing
to do it this way.  Since you are working with an existing schema, you'll want to set the
data dictionary property StoreCharsAsNumbers to "false".  Most of the data dictionaries are
defaulted to "true".  To override this default, you can set the following property in your
persistence.xml (substituting that data dictionary of your choice):

<property name="openjpa.jdbc.DBDictionary" value="db2(StoreCharsAsNumbers=false)"/>

For reference, the other overridable attributes are listed in our documentation:

http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#ref_guide_dbsetup_dbdictprops
                
> Wrong handling of char property
> -------------------------------
>
>                 Key: OPENJPA-2382
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2382
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.2.2
>         Environment: Spring 3.2.1
> spring-data-jpa 1.3.0
> mysql 5.5.31
>            Reporter: Alessandro Polverini
>
> I have an entity with a property defined in this way:
>   @Column(name = "type", columnDefinition = "char")
>   private char type = 'C';
> The column definition in the mysql table is char(1) and when I try to persist the entity
I got an error saying that the column is not wide enough and the data would be truncated.
> I then changed to column from char to varchar(10) and I discovered that openjpa is saving
the ascii code of the char in the column instead of the char itself.
> So for example I had a '67' value instead of 'C'.
> The same program runs perfectly fine with Hibernate.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message