-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Dialect specific SQL code in CREATE TABLE statements
PostPosted: Thu Jul 29, 2004 8:13 am 
Newbie

Joined: Thu Jul 29, 2004 7:31 am
Posts: 2
Hi!

Using Hibernate 2.1.4 is there any way to specify dialect specific SQL code to fine-tune how a CREATE TABLE statement will turn out? We're currently using MySQL 4.1.3-beta and would like to specify a column's collation which is different from the default table collation.

The CREATE TABLE statement should look something like this:

Code:
CREATE TABLE Test
(
    id INTEGER,
    email VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin
);


In a mapping file for a property we would like to do something like:

Code:
<property name="email" type="string">
    <dialect-specific dialect="mysql" code="CHARACTER SET utf8 COLLATE utf8_bin"/>
</property>


It there any way to achieve this? We could of course use extra database specific scripts to alter the tables after they have been created but it would be nice to get the correct statements directly from hibernate.

Regards,
Niklas Therning


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 10:58 am 
Regular
Regular

Joined: Tue Oct 28, 2003 8:25 am
Posts: 72
Location: Belgium
I guess you can specify this in the sql-type parameter:

Code:
<property name="email" type="string" sql-type="VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin" />


Not sure but you should give it a try.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 30, 2004 2:30 am 
Newbie

Joined: Thu Jul 29, 2004 7:31 am
Posts: 2
Thanks for the help! The following works like a charm:

Code:
<property name="email" type="string">
    <column name="email" sql-type="VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin"/>
</property>


The only problem with this is when we switch from MySQL to another dialect. I guess that won't happen that often, though.

Regards,
Niklas Therning


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.