hibernate不能自动创建表的问题,版本和教材不一的原因。基本上是因为用错了dialect的原因。
以下信息来自hibernate官网文档
http://docs.jboss.org/hibernate/orm/5.1/userguide/html_single/Hibernate_User_Guide.html#database-dialect
6.12. Database Dialect
Although SQL is relatively standardized, each database vendor uses a subset and superset of ANSI SQL defined syntax. This is referred to as the database’s dialect. Hibernate handles variations across these dialects through itsorg.hibernate.dialect.Dialect
class and the various subclasses for each database vendor.
In most cases Hibernate will be able to determine the proper Dialect to use by asking some questions of the JDBC Connection during bootstrap. For information on Hibernate’s ability to determine the proper Dialect to use (and your ability to influence that resolution), see Dialect resolution.
If for some reason it is not able to determine the proper one or you want to use a custom Dialect, you will need to set thehibernate.dialect
setting.
Dialect (short name) | Remarks |
---|---|
Cache71 | Support for the Caché database, version 2007.1 |
CUBRID | Support for the CUBRID database, version 8.3. May work with later versions. |
DB2 | Support for the DB2 database |
DB2390 | Support for DB2 Universal Database for OS/390, also known as DB2/390. |
DB2400 | Support for DB2 Universal Database for iSeries, also known as DB2/400. |
DerbyTenFive | Support for the Derby database, version 10.5 |
DerbyTenSix | Support for the Derby database, version 10.6 |
DerbyTenSeven | Support for the Derby database, version 10.7 |
Firebird | Support for the Firebird database |
FrontBase | Support for the Frontbase database |
H2 | Support for the H2 database |
HSQL | Support for the HSQL (HyperSQL) database |
Informix | Support for the Informix database |
Ingres | Support for the Ingres database, version 9.2 |
Ingres9 | Support for the Ingres database, version 9.3. May work with newer versions |
Ingres10 | Support for the Ingres database, version 10. May work with newer versions |
Interbase | Support for the Interbase database. |
JDataStore | Support for the JDataStore database |
McKoi | Support for the McKoi database |
Mimer | Support for the Mimer database, version 9.2.1. May work with newer versions |
MySQL5 | Support for the MySQL database, version 5.x |
MySQL5InnoDB | Support for the MySQL database, version 5.x preferring the InnoDB storage engine when exporting tables. |
MySQL57InnoDB | Support for the MySQL database, version 5.7 preferring the InnoDB storage engine when exporting tables. May work with newer versions |
Oracle8i | Support for the Oracle database, version 8i |
Oracle9i | Support for the Oracle database, version 9i |
Oracle10g | Support for the Oracle database, version 10g |
Pointbase | Support for the Pointbase database |
PostgresPlus | Support for the Postgres Plus database |
PostgreSQL81 | Support for the PostgrSQL database, version 8.1 |
PostgreSQL82 | Support for the PostgreSQL database, version 8.2 |
PostgreSQL9 | Support for the PostgreSQL database, version 9. May work with later versions. |
Progress | Support for the Progress database, version 9.1C. May work with newer versions. |
SAPDB | Support for the SAPDB/MAXDB database. |
SQLServer | Support for the SQL Server 2000 database |
SQLServer2005 | Support for the SQL Server 2005 database |
SQLServer2008 | Support for the SQL Server 2008 database |
Sybase11 | Support for the Sybase database, up to version 11.9.2 |
SybaseAnywhere | Support for the Sybase Anywhere database |
SybaseASE15 | Support for the Sybase Adaptive Server Enterprise database, version 15 |
SybaseASE157 | Support for the Sybase Adaptive Server Enterprise database, version 15.7. May work with newer versions. |
Teradata | Support for the Teradata database |
TimesTen | Support for the TimesTen database, version 5.1. May work with newer versions |