1 package com.salto.db.generator.plugin; 2 3 import java.sql.DatabaseMetaData; 4 import java.sql.SQLException; 5 import java.util.HashMap; 6 import java.util.Map; 7 8 /*** 9 * @author remi 10 * 11 */ 12 public final class HibernateDialectHelper { 13 14 private static final Map dialects = new HashMap(); 15 16 static { 17 dialects.put("Oracle", "org.hibernate.dialect.OracleDialect"); 18 dialects.put("Microsoft SQL Server", "org.hibernate.dialect.SQLServerDialect"); 19 dialects.put("PostgreSQL", "org.hibernate.dialect.PostgreSQLDialect"); 20 dialects.put("HypersonicSQL", "org.hibernate.dialect.HSQLDialect"); 21 22 } 23 24 public final String getHibernateDialect(DatabaseMetaData metaData) throws SQLException { 25 if (metaData == null) 26 return null; 27 28 29 if (metaData.getDatabaseProductName().equals("MySQL")) { 30 if (metaData.getDatabaseMajorVersion() >= 5) { 31 return "org.hibernate.dialect.MySQL5Dialect"; 32 } 33 return "org.hibernate.dialect.MySQLDialect"; 34 } else 35 return (String) dialects.get(metaData.getDatabaseProductName()); 36 37 } 38 39 }