You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by William Cai <wc...@xwarelabs.com> on 2007/01/31 07:48:13 UTC

Is it possible to extend SchemaTool with MS SQL Server collation setting?

Folks,
I used SchemaTool to create tables in MS SQL Server, but the schema file
structure is pretty simple, so some SQL Server specific setting can't be set
with SchemaTool. Does SchemaTool allow custom extension so that I can create
a table with collation setting in MS SQL?

Thanks,
William

Re: Is it possible to extend SchemaTool with MS SQL Server collation setting?

Posted by William Cai <wc...@xwarelabs.com>.
Wow~~~ You're the man, Marc! The problem is resolved!

On 1/31/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> William-
>
> If you wanted to have all your varchar columns be specified as
> "varchar(SIZE) COLLATE French_CI_AS", you could specify the property:
>
>     openjpa.jdbc.DBDictionary: VarcharTypeName="varchar{0} COLLATE
> French_CI_AS"
>
>
>
>
> On Jan 31, 2007, at 12:39 AM, William Cai wrote:
>
> > Marc,
> > In SQL Server, we specify Collation with below code. Therefore, we
> > can't set
> > the option in "type-name". In our project, there are hundreds of
> > columns
> > need case-sensitive collation support. It's really painful to set
> > all of
> > them in generated script. The best solution is custom
> > SQLServerDictionary.
> > I'll try it. Perhaps we need improve SQLServerDictionary at a
> > point. :-)
> > Thanks a lot for your help.
> >
> > CREATE TABLE MyTable
> >  (PrimaryKey   int PRIMARY KEY,
> >   CharCol      varchar(10) COLLATE French_CI_AS NOT NULL
> >  )
> > GO
> >
> >
> >
> >
> > On 1/31/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >>
> >> William-
> >>
> >> I don't know how you specify collation, but if it is expressible via
> >> the column type name, you could always set the "type-name" of the
> >> column in the schema file (e.g., setting the type-name to be "VARCHAR
> >> WITH ASCII COLLATION").
> >>
> >> If it needs to be specific in the "CREATE TABLE" part, then the
> >> schematool doesn't have any built-in way to alter that. However, you
> >> can always make a custom subclass of the SQLServerDictionary and
> >> override the "public String[] getCreateTableSQL(Table table)" method,
> >> and make it do whatever you want.
> >>
> >> Lastly, you could always use the default SQL generated by the
> >> schematool, and then just follow up with some custom SQL that issues
> >> "ALTER TABLE" statements that change whatever attributes of the
> >> tables you want.
> >>
> >>
> >> On Jan 30, 2007, at 10:48 PM, William Cai wrote:
> >>
> >> > Folks,
> >> > I used SchemaTool to create tables in MS SQL Server, but the schema
> >> > file
> >> > structure is pretty simple, so some SQL Server specific setting
> >> > can't be set
> >> > with SchemaTool. Does SchemaTool allow custom extension so that I
> >> > can create
> >> > a table with collation setting in MS SQL?
> >> >
> >> > Thanks,
> >> > William
> >>
> >>
>
>

Re: Is it possible to extend SchemaTool with MS SQL Server collation setting?

Posted by Marc Prud'hommeaux <mp...@apache.org>.
William-

If you wanted to have all your varchar columns be specified as  
"varchar(SIZE) COLLATE French_CI_AS", you could specify the property:

    openjpa.jdbc.DBDictionary: VarcharTypeName="varchar{0} COLLATE  
French_CI_AS"




On Jan 31, 2007, at 12:39 AM, William Cai wrote:

> Marc,
> In SQL Server, we specify Collation with below code. Therefore, we  
> can't set
> the option in "type-name". In our project, there are hundreds of  
> columns
> need case-sensitive collation support. It's really painful to set  
> all of
> them in generated script. The best solution is custom  
> SQLServerDictionary.
> I'll try it. Perhaps we need improve SQLServerDictionary at a  
> point. :-)
> Thanks a lot for your help.
>
> CREATE TABLE MyTable
>  (PrimaryKey   int PRIMARY KEY,
>   CharCol      varchar(10) COLLATE French_CI_AS NOT NULL
>  )
> GO
>
>
>
>
> On 1/31/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>>
>> William-
>>
>> I don't know how you specify collation, but if it is expressible via
>> the column type name, you could always set the "type-name" of the
>> column in the schema file (e.g., setting the type-name to be "VARCHAR
>> WITH ASCII COLLATION").
>>
>> If it needs to be specific in the "CREATE TABLE" part, then the
>> schematool doesn't have any built-in way to alter that. However, you
>> can always make a custom subclass of the SQLServerDictionary and
>> override the "public String[] getCreateTableSQL(Table table)" method,
>> and make it do whatever you want.
>>
>> Lastly, you could always use the default SQL generated by the
>> schematool, and then just follow up with some custom SQL that issues
>> "ALTER TABLE" statements that change whatever attributes of the
>> tables you want.
>>
>>
>> On Jan 30, 2007, at 10:48 PM, William Cai wrote:
>>
>> > Folks,
>> > I used SchemaTool to create tables in MS SQL Server, but the schema
>> > file
>> > structure is pretty simple, so some SQL Server specific setting
>> > can't be set
>> > with SchemaTool. Does SchemaTool allow custom extension so that I
>> > can create
>> > a table with collation setting in MS SQL?
>> >
>> > Thanks,
>> > William
>>
>>


Re: Is it possible to extend SchemaTool with MS SQL Server collation setting?

Posted by William Cai <wc...@xwarelabs.com>.
Marc,
In SQL Server, we specify Collation with below code. Therefore, we can't set
the option in "type-name". In our project, there are hundreds of columns
need case-sensitive collation support. It's really painful to set all of
them in generated script. The best solution is custom SQLServerDictionary.
I'll try it. Perhaps we need improve SQLServerDictionary at a point. :-)
Thanks a lot for your help.

CREATE TABLE MyTable
  (PrimaryKey   int PRIMARY KEY,
   CharCol      varchar(10) COLLATE French_CI_AS NOT NULL
  )
GO




On 1/31/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> William-
>
> I don't know how you specify collation, but if it is expressible via
> the column type name, you could always set the "type-name" of the
> column in the schema file (e.g., setting the type-name to be "VARCHAR
> WITH ASCII COLLATION").
>
> If it needs to be specific in the "CREATE TABLE" part, then the
> schematool doesn't have any built-in way to alter that. However, you
> can always make a custom subclass of the SQLServerDictionary and
> override the "public String[] getCreateTableSQL(Table table)" method,
> and make it do whatever you want.
>
> Lastly, you could always use the default SQL generated by the
> schematool, and then just follow up with some custom SQL that issues
> "ALTER TABLE" statements that change whatever attributes of the
> tables you want.
>
>
> On Jan 30, 2007, at 10:48 PM, William Cai wrote:
>
> > Folks,
> > I used SchemaTool to create tables in MS SQL Server, but the schema
> > file
> > structure is pretty simple, so some SQL Server specific setting
> > can't be set
> > with SchemaTool. Does SchemaTool allow custom extension so that I
> > can create
> > a table with collation setting in MS SQL?
> >
> > Thanks,
> > William
>
>

Re: Is it possible to extend SchemaTool with MS SQL Server collation setting?

Posted by Marc Prud'hommeaux <mp...@apache.org>.
William-

I don't know how you specify collation, but if it is expressible via  
the column type name, you could always set the "type-name" of the  
column in the schema file (e.g., setting the type-name to be "VARCHAR  
WITH ASCII COLLATION").

If it needs to be specific in the "CREATE TABLE" part, then the  
schematool doesn't have any built-in way to alter that. However, you  
can always make a custom subclass of the SQLServerDictionary and  
override the "public String[] getCreateTableSQL(Table table)" method,  
and make it do whatever you want.

Lastly, you could always use the default SQL generated by the  
schematool, and then just follow up with some custom SQL that issues  
"ALTER TABLE" statements that change whatever attributes of the  
tables you want.


On Jan 30, 2007, at 10:48 PM, William Cai wrote:

> Folks,
> I used SchemaTool to create tables in MS SQL Server, but the schema  
> file
> structure is pretty simple, so some SQL Server specific setting  
> can't be set
> with SchemaTool. Does SchemaTool allow custom extension so that I  
> can create
> a table with collation setting in MS SQL?
>
> Thanks,
> William