Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » DatabasePlatform: convert varchar to nvarchar for ms sql server(by default, when creating database on sql server, varchar type is created, but in order to support unicode, need nvarchar)
DatabasePlatform: convert varchar to nvarchar for ms sql server [message #825298] Tue, 20 March 2012 17:46 Go to next message
Keith Chen is currently offline Keith ChenFriend
Messages: 2
Registered: March 2012
Junior Member
need help. I am working on a project to use Eclipselink/JPA to create databases across different database platforms. The requirement is that the created database needs to support Unicode. my code runs well on Oracle, Derby, and other types, but on MS sql server, a varchar type is created by Eclipselink by default. In order to support Unicode, I need nvarchar rather than varchar.

I am not very sure how to implement to intervene Eclipselink's default behavior. I am looking at the org.eclipse.persistence.platform.database.MySQLPlatform, and want to override it, but don't know how to do.

Please give some help!
Re: DatabasePlatform: convert varchar to nvarchar for ms sql server [message #829634 is a reply to message #825298] Mon, 26 March 2012 15:23 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

In the buildFieldTypes() method change String to map to NVARCHAR instead of VARCHAR.
You can subclass MySQLPlatform with your own class and specify it as your target-database in your persistence.xml.

You could also specify the columnDefinition on your JPA @Column annotation.


James : Wiki : Book : Blog : Twitter
Re: DatabasePlatform: convert varchar to nvarchar for ms sql server [message #829725 is a reply to message #829634] Mon, 26 March 2012 17:47 Go to previous message
Keith Chen is currently offline Keith ChenFriend
Messages: 2
Registered: March 2012
Junior Member
James,

Thank you for the reply. Yes, I got into the same direction and it worked as breeze.
I really appreciate.

[Updated on: Mon, 26 March 2012 17:47]

Report message to a moderator

Previous Topic:deadlock in a LAZY fetch
Next Topic:Generate Entities from Tables (Postgres)
Goto Forum:
  


Current Time: Thu Apr 25 21:33:20 GMT 2024

Powered by FUDForum. Page generated in 0.02854 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top