Discussion:
[nhusers] How persist euro symbol in oracle database with NH
Felipe Oriani
2017-12-07 16:08:38 UTC
Permalink
Hi,

We have a database which we store the currencies of the world. We have a
column called Symbol which the datatype is VARCHAR(20). It is a Oracle
database and we are mapping in a string property with Fluent NHibernate
like this:

Map(x => x.Symbol).Not.Nullable();

In this column we store the symbol for the currency. For sample: U$
(dolar), £ (pounds), R$ (real - brazil), € (euro).

The problem is with the € symbol for Euro Currency, when we try it,
nhibernate save on the database the ¿ char, instead of €. We have tried to
map the column using AnsiString, for sample:

Map(x => x.Symbol).CustomType("AnsiString").Not.Nullable();

but it does not work as expected.

If we hit a insert sql statement on the database it works as expected but
nhibernate cannot read it and give the ¿ char.

How can we solve it?

Thank you.
--
______________________________________
Felipe B Oriani
***@gmail.com
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Fran Knebels
2017-12-07 16:14:51 UTC
Permalink
Aren't those symbols Unicode? You would need to store them in an nvarchar
column.

Conversely , you could store the html value in the column which would be
ASCII

On Dec 7, 2017 11:09 AM, "Felipe Oriani" <***@gmail.com> wrote:

Hi,

We have a database which we store the currencies of the world. We have a
column called Symbol which the datatype is VARCHAR(20). It is a Oracle
database and we are mapping in a string property with Fluent NHibernate
like this:

Map(x => x.Symbol).Not.Nullable();

In this column we store the symbol for the currency. For sample: U$
(dolar), £ (pounds), R$ (real - brazil), € (euro).

The problem is with the € symbol for Euro Currency, when we try it,
nhibernate save on the database the ¿ char, instead of €. We have tried to
map the column using AnsiString, for sample:

Map(x => x.Symbol).CustomType("AnsiString").Not.Nullable();

but it does not work as expected.

If we hit a insert sql statement on the database it works as expected but
nhibernate cannot read it and give the ¿ char.

How can we solve it?

Thank you.
--
______________________________________
Felipe B Oriani
***@gmail.com
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Felipe Oriani
2017-12-07 16:32:10 UTC
Permalink
@Fran,

Yes, we think about it, to persist some code and convert it on our code to
show on the UI layer but it is our last option. I would like to know if
there is a way to persist it on oracle using nhibernate, because if we run
a insert sql statement directly on the database (pl/sql), it saves fine.

Thank you.
Post by Fran Knebels
Aren't those symbols Unicode? You would need to store them in an nvarchar
column.
Conversely , you could store the html value in the column which would be
ASCII
Hi,
We have a database which we store the currencies of the world. We have a
column called Symbol which the datatype is VARCHAR(20). It is a Oracle
database and we are mapping in a string property with Fluent NHibernate
Map(x => x.Symbol).Not.Nullable();
In this column we store the symbol for the currency. For sample: U$
(dolar), £ (pounds), R$ (real - brazil), € (euro).
The problem is with the € symbol for Euro Currency, when we try it,
nhibernate save on the database the ¿ char, instead of €. We have tried to
Map(x => x.Symbol).CustomType("AnsiString").Not.Nullable();
but it does not work as expected.
If we hit a insert sql statement on the database it works as expected but
nhibernate cannot read it and give the ¿ char.
How can we solve it?
Thank you.
--
______________________________________
Felipe B Oriani
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
______________________________________
Felipe B Oriani
***@gmail.com
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Oskar Berggren
2017-12-07 19:03:45 UTC
Permalink
The euro symbol is defined in code page ISO-8859-15 - I'm not very familiar
with Oracle, but it would seem that the Oracle client driver (from Oracle)
doesn't use ISO-8859-15 or doesn't agree with the server what encoding to
use.

NHibernate sends .Net strings (internally encoded as UTF-16 I believe) to
the Oracle driver and it's up to the driver to send them correctly to and
from the server. Maybe this is something you can configure in the
connection string?

/Oskar
Post by Felipe Oriani
@Fran,
Yes, we think about it, to persist some code and convert it on our code to
show on the UI layer but it is our last option. I would like to know if
there is a way to persist it on oracle using nhibernate, because if we run
a insert sql statement directly on the database (pl/sql), it saves fine.
Thank you.
Post by Fran Knebels
Aren't those symbols Unicode? You would need to store them in an
nvarchar column.
Conversely , you could store the html value in the column which would be
ASCII
Hi,
We have a database which we store the currencies of the world. We have a
column called Symbol which the datatype is VARCHAR(20). It is a Oracle
database and we are mapping in a string property with Fluent NHibernate
Map(x => x.Symbol).Not.Nullable();
In this column we store the symbol for the currency. For sample: U$
(dolar), £ (pounds), R$ (real - brazil), € (euro).
The problem is with the € symbol for Euro Currency, when we try it,
nhibernate save on the database the ¿ char, instead of €. We have tried to
Map(x => x.Symbol).CustomType("AnsiString").Not.Nullable();
but it does not work as expected.
If we hit a insert sql statement on the database it works as expected but
nhibernate cannot read it and give the ¿ char.
How can we solve it?
Thank you.
--
______________________________________
Felipe B Oriani
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
______________________________________
Felipe B Oriani
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Loading...