You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by is_maximum <mn...@gmail.com> on 2009/12/30 06:44:06 UTC

problem with NChar in Oracle 10g

Hello
When a field of type nchar is read by OpenJPA the lenght of read value is
constant and equals to the lenght of the field but if the lenght of value is
less than the lenght of field the remained are filled with space or strange
characters and we can't even trim that string value to remove the spaces. As
I read the Oracle readme about nchars, they stated to use setFormOfUse and
in OpenJPA manual it is said that OpenJPA is automatically uses this method
if it find a field of type nchar and nvarchar but still we have problem. And
for your information, we didn't insert any international-character into such
field. It is also said we can use  system property
-Doracle.jdbc.defaultNChar=true but I am reluctant to set this value in App
server. I am eager to know if we can set system property in persistence xml?

I appreciate if you share your experiences about this with me

thanks

-----
--
Regards
Mohammad
http://pixelshot.wordpress.com Pixelshot 
-- 
View this message in context: http://n2.nabble.com/problem-with-NChar-in-Oracle-10g-tp4231056p4231056.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: problem with NChar in Oracle 10g

Posted by MiƂosz Tylenda <mt...@o2.pl>.
Hi Mohammad,

I don't think we can set a system property by using persistence.xml and even if we could, that would affect your entire app server anyways. System properties affect the whole JVM even if set during runtime.

The Oracle doc you mentioned [1] suggests that you can use oracle.jdbc.defaultNChar also as a connection property. JDBC drivers usually allow you to set connection properties by appending them to connection strings. I am not sure whether Oracle driver allows it, if it does, you could modify the connection string in the data source definition and you should be done. Also, some app servers might be able to call connProps.setProperty(..., ...) when a connection is taken from the pool.

I am suspecting that your problem is not specific to NCHAR but to CHAR columns in general. It might be that reading a CHAR column through JDBC returns its value right-padded with spaces to the length of the column. Is it possible that you try your test case with CHAR instead of NCHAR and confirm whether the behaviour is similar?

As for strange characters instead of spaces - I would try another version of the JDBC driver. For example, if your driver major version is higher than your database major version, I would test the driver which matches major version of the database.

Cheers,
Milosz

[1] http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/nchar/readme.html


> 
> Hello
> When a field of type nchar is read by OpenJPA the lenght of read value is
> constant and equals to the lenght of the field but if the lenght of value is
> less than the lenght of field the remained are filled with space or strange
> characters and we can't even trim that string value to remove the spaces. As
> I read the Oracle readme about nchars, they stated to use setFormOfUse and
> in OpenJPA manual it is said that OpenJPA is automatically uses this method
> if it find a field of type nchar and nvarchar but still we have problem. And
> for your information, we didn't insert any international-character into such
> field. It is also said we can use  system property
> -Doracle.jdbc.defaultNChar=true but I am reluctant to set this value in App
> server. I am eager to know if we can set system property in persistence xml?
> 
> I appreciate if you share your experiences about this with me
> 
> thanks
> 
> -----
> --
> Regards
> Mohammad
> http://pixelshot.wordpress.com Pixelshot 
> -- 
> View this message in context: http://n2.nabble.com/problem-with-NChar-in-Oracle-10g-tp4231056p4231056.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>