org.hibernate.dialect.MySQL5Dialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of beangle-hibernate-core Show documentation
Show all versions of beangle-hibernate-core Show documentation
Hibernate Orm Core Shade,Support Scala Collection
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.dialect;
import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.dialect.hint.IndexQueryHintHandler;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
/**
* An SQL dialect for MySQL 5.x specific features.
*
* @author Steve Ebersole
*/
public class MySQL5Dialect extends MySQLDialect {
@Override
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
registerColumnType( Types.VARCHAR, 65535, "varchar($l)" );
registerColumnType( Types.LONGVARCHAR, "longtext" );
}
@Override
public boolean supportsColumnCheck() {
return false;
}
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
}
protected String getEngineKeyword() {
return "engine";
}
private static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
@Override
protected String doExtractConstraintName(SQLException sqle) throws NumberFormatException {
final int sqlState = Integer.parseInt( JdbcExceptionHelper.extractSqlState( sqle ) );
switch ( sqlState ) {
case 23000:
return extractUsingTemplate( " for key '", "'", sqle.getMessage() );
default:
return null;
}
}
};
@Override
public String getQueryHintString(String query, String hints) {
return IndexQueryHintHandler.INSTANCE.addQueryHints( query, hints );
}
@Override
public boolean supportsUnionAll() {
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy