|
|
@ -9,9 +9,11 @@ package com.fr.third.org.hibernate.dialect; |
|
|
|
import com.fr.third.org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; |
|
|
|
import com.fr.third.org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; |
|
|
|
import com.fr.third.org.hibernate.exception.spi.ViolatedConstraintNameExtracter; |
|
|
|
import com.fr.third.org.hibernate.exception.spi.ViolatedConstraintNameExtracter; |
|
|
|
import com.fr.third.org.hibernate.internal.util.JdbcExceptionHelper; |
|
|
|
import com.fr.third.org.hibernate.internal.util.JdbcExceptionHelper; |
|
|
|
|
|
|
|
import com.fr.third.org.hibernate.mapping.Column; |
|
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.Types; |
|
|
|
import java.sql.Types; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* An SQL dialect for MySQL 5.x specific features. |
|
|
|
* An SQL dialect for MySQL 5.x specific features. |
|
|
@ -19,6 +21,9 @@ import java.sql.Types; |
|
|
|
* @author Steve Ebersole |
|
|
|
* @author Steve Ebersole |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MySQL5Dialect extends MySQLDialect { |
|
|
|
public class MySQL5Dialect extends MySQLDialect { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int INDEX_LENGTH_LIMIT = 255; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void registerVarcharTypes() { |
|
|
|
protected void registerVarcharTypes() { |
|
|
|
registerColumnType( Types.VARCHAR, "longtext" ); |
|
|
|
registerColumnType( Types.VARCHAR, "longtext" ); |
|
|
@ -32,6 +37,18 @@ public class MySQL5Dialect extends MySQLDialect { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//utf8编码下,mysql5.7以下版本主键长度不能超过255,故特殊处理,去掉它的primary。
|
|
|
|
|
|
|
|
// 它默认会生成一个长度为255的前缀索引
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String getPrimaryKeyString(List<Column> columnList) { |
|
|
|
|
|
|
|
for (Column column : columnList) { |
|
|
|
|
|
|
|
if (column.getLength() > INDEX_LENGTH_LIMIT) { |
|
|
|
|
|
|
|
return "key"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return "primary key"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() { |
|
|
|
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() { |
|
|
|
return EXTRACTER; |
|
|
|
return EXTRACTER; |
|
|
|
} |
|
|
|
} |
|
|
|