Created
November 3, 2009 22:51
-
-
Save vgrichina/225543 to your computer and use it in GitHub Desktop.
Improved MSSQL dialect for Hibernate (using more appropriate data types)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright © 2009, Componentix. All rights reserved. | |
*/ | |
package com.componentix.hibernate.dialect; | |
import java.sql.Types; | |
/** | |
* A proper dialect for Microsoft SQL Server 2000 and 2005. | |
* | |
* @author Yuri Sakhno (George1) | |
*/ | |
public class SQLServerDialect extends org.hibernate.dialect.SQLServerDialect { | |
/** | |
* Initializes a new instance of the {@link SQLServerDialect} class. | |
*/ | |
public SQLServerDialect() { | |
registerColumnType(Types.BIGINT, "bigint"); | |
registerColumnType(Types.BIT, "bit"); | |
registerColumnType(Types.CHAR, "nchar(1)"); | |
registerColumnType(Types.VARCHAR, 4000, "nvarchar($l)"); | |
registerColumnType(Types.VARCHAR, "nvarchar(max)"); | |
registerColumnType(Types.VARBINARY, 4000, "varbinary($1)"); | |
registerColumnType(Types.VARBINARY, "varbinary(max)"); | |
registerColumnType(Types.BLOB, "varbinary(max)"); | |
registerColumnType(Types.CLOB, "nvarchar(max)"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello there,
We're currently running into the following problem while our Dialect class extends SQLServer2012Dialect any suggestions will be greatly appreciated.
14:44:29,884 ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper Only dates between January 1, 1753 and December 31, 9999 are accepted.
Just to give you a background :
My dialect class datetime looks like this :
registerColumnType(Types.DATE, "datetime2(0)");
and I've updated all my SQL date fields to datetime2(0) do you see any issue why I've ended up in the error above ?