You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Rolf Schumacher <ro...@august.de> on 2009/03/18 07:03:09 UTC

problems with char field

I'm new to jpa and openjpa and to this list:

1. how to search the archives? I found
http://mail-archives.apache.org/mod_mbox/openjpa-users/ where I can not
figure out how to search

2. In my first attempt to use openjpa with netbeans/maven I created
classes from an existing mysql db. everything worked fine until I added
a table with a char typed column. I got an exception telling me, that
there is a type conflict, because 'Y' is not an integer.

As I commented the private char variable and its accessors everything
worked fine again, accept that I can not get hold of the char column.

I googled and found something which I did not understand.

Do you have any point of clarification for me?

rolf


Re: problems with char field

Posted by Rolf Schumacher <ma...@august.de>.
Yes, thank you, Michael

it worked as you've pointed out.

Michael Dick wrote:
> Hi Rolf,
>
> I use markmail [1]  to search the mail archives, but a lot of people like
> Nabble [2] too.
>
> Regarding your problem with characters. OpenJPA expects characters to be
> stored as ints by default. So if you update the table and don't regen the
> classes with the tool you might not get the value you expect.
>
> You can tell OpenJPA to use chars by adding a configuration property like
> this one to persistence.xml :
> <property name="openjpa.jdbc.DBDictionary"
> value="mysql(storeCharsAsNumbers=false)"/>
>
> [1] http://openjpa.markmail.org/
> [2] http://n2.nabble.com/OpenJPA-f208410.html
>
> Hope this helps,
> -mike
>
> On Wed, Mar 18, 2009 at 1:03 AM, Rolf Schumacher <ro...@august.de> wrote:
>
>   
>> I'm new to jpa and openjpa and to this list:
>>
>> 1. how to search the archives? I found
>> http://mail-archives.apache.org/mod_mbox/openjpa-users/ where I can not
>> figure out how to search
>>
>> 2. In my first attempt to use openjpa with netbeans/maven I created
>> classes from an existing mysql db. everything worked fine until I added
>> a table with a char typed column. I got an exception telling me, that
>> there is a type conflict, because 'Y' is not an integer.
>>
>> As I commented the private char variable and its accessors everything
>> worked fine again, accept that I can not get hold of the char column.
>>
>> I googled and found something which I did not understand.
>>
>> Do you have any point of clarification for me?
>>
>> rolf
>>
>>
>>     
>
>   

Re: problems with char field

Posted by Michael Dick <mi...@gmail.com>.
Hi Rolf,

I use markmail [1]  to search the mail archives, but a lot of people like
Nabble [2] too.

Regarding your problem with characters. OpenJPA expects characters to be
stored as ints by default. So if you update the table and don't regen the
classes with the tool you might not get the value you expect.

You can tell OpenJPA to use chars by adding a configuration property like
this one to persistence.xml :
<property name="openjpa.jdbc.DBDictionary"
value="mysql(storeCharsAsNumbers=false)"/>

[1] http://openjpa.markmail.org/
[2] http://n2.nabble.com/OpenJPA-f208410.html

Hope this helps,
-mike

On Wed, Mar 18, 2009 at 1:03 AM, Rolf Schumacher <ro...@august.de> wrote:

> I'm new to jpa and openjpa and to this list:
>
> 1. how to search the archives? I found
> http://mail-archives.apache.org/mod_mbox/openjpa-users/ where I can not
> figure out how to search
>
> 2. In my first attempt to use openjpa with netbeans/maven I created
> classes from an existing mysql db. everything worked fine until I added
> a table with a char typed column. I got an exception telling me, that
> there is a type conflict, because 'Y' is not an integer.
>
> As I commented the private char variable and its accessors everything
> worked fine again, accept that I can not get hold of the char column.
>
> I googled and found something which I did not understand.
>
> Do you have any point of clarification for me?
>
> rolf
>
>