users@glassfish.java.net

RE: Problems with Oracle's CHAR datatype and JPA

From: Kenneth Clark <kenneth.clark_at_skyetech.co.za>
Date: Thu, 10 Jan 2008 22:09:20 +0200

On second thought the padding won't work :(

I remember that Oracle stores with the padding but when you run it through the entitymanager the whitespace got stripped out. In postgresql it worked as expected but in Oracle the space was trimmed out which led me to believe it resides in the JDBC Drivers.

________________
Thanks and regards

Kenneth Clark
Solutions Engineer


Tel: 27 (0) 11 679 3075
Fax: 27 (0) 86 647 4819
Mobile: 27 (0) 84 583 1348
Email: kenneth.clark_at_skyetech.co.za
Website: http://www.skyetech.co.za


-----Original Message-----
From: Kenneth Clark [mailto:kenneth.clark_at_skyetech.co.za]
Sent: 10 January 2008 22:04
To: users_at_glassfish.dev.java.net
Subject: RE: Problems with Oracle's CHAR datatype and JPA

Sorry I didn't read your first post properly :(. Maybe there is a trim function that discards the white space. I got the feeling this actually resides in the Oracle JDBC drivers.

Another option would be to pad the char with white space before persisting it?

Try
@PrePersist


________________
Thanks and regards

Kenneth Clark
Solutions Engineer


Tel: 27 (0) 11 679 3075
Fax: 27 (0) 86 647 4819
Mobile: 27 (0) 84 583 1348
Email: kenneth.clark_at_skyetech.co.za
Website: http://www.skyetech.co.za


-----Original Message-----
From: Kenneth Clark [mailto:kenneth.clark_at_skyetech.co.za]
Sent: 10 January 2008 21:59
To: users_at_glassfish.dev.java.net
Subject: RE: Problems with Oracle's CHAR datatype and JPA

I had a similar issue and it almost drove me mad. The resolution for me was to have the char lengths all the same size (fitting the data). The only thing I can think of if you need variable data lengths in the fields is to change the type varchar. I don't know if this is a viable solution.

________________
Thanks and regards

Kenneth Clark
Solutions Engineer


Tel: 27 (0) 11 679 3075
Fax: 27 (0) 86 647 4819
Mobile: 27 (0) 84 583 1348
Email: kenneth.clark_at_skyetech.co.za
Website: http://www.skyetech.co.za

-----Original Message-----
From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
Sent: 10 January 2008 21:53
To: users_at_glassfish.dev.java.net
Subject: Re: Problems with Oracle's CHAR datatype and JPA

More updates:

I can also get correct results if I right pad my parameter value to the desired length (in which case I can use [i]=[/i] instead of [i]like[/i]), but when it tries to do foreign key matching it still fails:

SELECT USERID <...> WHERE (USERID = ?)
        bind => [151504 ] //note the spaces here

but as it goes through the joins . . .

SELECT t1.USERID <...> t1 WHERE ((t0.USERID = ?) <...>
        bind => [151504]

. . . it loses the padding.

I even changed my getter and setter in my entity to right pad just in case.
[Message sent by forum member 'marcusocasey' (marcusocasey)]

http://forums.java.net/jive/thread.jspa?messageID=253265

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38
 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38
 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.13/1214 - Release Date: 2008/01/08 13:38