Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsConvert varchar to nvarchar for specific columns only.
https://www.eclipse.org/forums/index.php/mv/msg/487366/1058376/#msg_1058376
The problem is that some indexes are varchar and some are nvarchar. By default all of the string values are sent as unicode. Previously we had used the query string parameter for SqlServer "sendStringParametersAsUnicode=false" which sends all strings as non-unicode by default, then we manually overrode the types for the nvarchar indexes in hibernate to make sure those specific ones were sent correctly. (This is to avoid SQL Server from doing a scan and effectively removing the advantage of the index in the first place)
My question is, is there a way to do the equivalent in EclipseLink? I have tried a SessionCustomizer to override the type for a specific column but it didn't seem to affect the resulting sql statement.
Any advice would be appreciated.
]]>Esta Chavez2013-05-13T18:43:42-00:00Re: Convert varchar to nvarchar for specific columns only.
https://www.eclipse.org/forums/index.php/mv/msg/487366/1058621/#msg_1058621
If you are using a DataSource you need to set it in your DataSource options, otherwise you can set it in your persistence.xml.
You can either set it a part of your JDBC URL
i.e. jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value]
or use the EclipseLink persistence property,
"eclipselink.jdbc.property.sendStringParametersAsUnicode"="false"
(requires EclipseLink 2.4)
]]>James Sutherland2013-05-14T14:53:14-00:00Re: Convert varchar to nvarchar for specific columns only.
https://www.eclipse.org/forums/index.php/mv/msg/487366/1058651/#msg_1058651
The part I can't figure out is how to override that value for specific columns. I need to be able to send both Unicode and non-Unicode strings within a single query.
]]>Esta Chavez2013-05-14T15:34:11-00:00Re: Convert varchar to nvarchar for specific columns only.
https://www.eclipse.org/forums/index.php/mv/msg/487366/1060012/#msg_1060012
EclipseLink does have some special support for NVARCHAR types for Oracle. Refer to the Oracle9Platform class for how it is done. You may need to do something similar for SQL Server.
If it is as simple as needing to call setNString() instead of setString(), or setObject() with including the type, then you could log a bug for this, it should be something that could be supported. You could probably support it yourself by subclassing the SQLServerPlatform.
]]>James Sutherland2013-05-22T14:19:59-00:00