[Hibernate]SchemaUpdate建立索引問(wèn)題
關(guān)鍵字: hibernate schemaupdate 索引當(dāng)hibernate的hbm2dll配置為
將會(huì)發(fā)現(xiàn)Hibernate不會(huì)為我們創(chuàng)建任何自定義的索引(不包括主鍵跟外鍵索引),不論你使用xml方式或者annotation進(jìn)行聲明配置
這個(gè)問(wèn)題在Hibernate的JIRA多次出現(xiàn),甚至有人專(zhuān)門(mén)為此發(fā)布了打了補(bǔ)丁的hibernate.jar
這個(gè)所謂的bug,在目前已發(fā)布的hibernate的版本中,一直都沒(méi)有解決,或者說(shuō)不予理睬(Gavin King個(gè)人認(rèn)為這個(gè)不是bug)
這里引用hibernate 3.2.5版的jira
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012
引用Hibernate上官方的解釋
The hibernate.hbm2ddl.auto=update setting doesn't create indexes
SchemaUpdate is activated by this configuration setting. SchemaUpdate is not really very powerful and comes without any warranties. For example, it does not create any indexes automatically. Furthermore, SchemaUpdate is only useful in development, per definition (a production schema is never updated automatically). You don't need indexes in development.
Hibernate doesn't generate the database indexes I want in the schema!
Automatic schema export (and update) by Hibernate tools is only useful in development. You never need indexes in development, they are purely for performance and scalability tuning in production systems. Production schemas are never automatically generated, at least not completely. A DBA adds indexes to the automatically generated schema during SQL tuning and testing of the application, before going into production with the (possibly automatically generated) base schema, and her handwritten optimized DDL. Also note that optimized DDL is highly vendor specific and totally dependent on the environment (SQL execution plans, tablespace configuration, caches, etc). Even if Hibernate developers would encourage you to automatically generate production-ready schemas (we don't, and we also don't like ad-hoc SQL tuning by throwing a bunch of indexes onto a schema), Hibernate could never offer such a feature.
- hibernate.hbm2ddl.auto update
這個(gè)問(wèn)題在Hibernate的JIRA多次出現(xiàn),甚至有人專(zhuān)門(mén)為此發(fā)布了打了補(bǔ)丁的hibernate.jar
這個(gè)所謂的bug,在目前已發(fā)布的hibernate的版本中,一直都沒(méi)有解決,或者說(shuō)不予理睬(Gavin King個(gè)人認(rèn)為這個(gè)不是bug)
這里引用hibernate 3.2.5版的jira
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012
引用Hibernate上官方的解釋
引用
The hibernate.hbm2ddl.auto=update setting doesn't create indexes
SchemaUpdate is activated by this configuration setting. SchemaUpdate is not really very powerful and comes without any warranties. For example, it does not create any indexes automatically. Furthermore, SchemaUpdate is only useful in development, per definition (a production schema is never updated automatically). You don't need indexes in development.
Hibernate doesn't generate the database indexes I want in the schema!
Automatic schema export (and update) by Hibernate tools is only useful in development. You never need indexes in development, they are purely for performance and scalability tuning in production systems. Production schemas are never automatically generated, at least not completely. A DBA adds indexes to the automatically generated schema during SQL tuning and testing of the application, before going into production with the (possibly automatically generated) base schema, and her handwritten optimized DDL. Also note that optimized DDL is highly vendor specific and totally dependent on the environment (SQL execution plans, tablespace configuration, caches, etc). Even if Hibernate developers would encourage you to automatically generate production-ready schemas (we don't, and we also don't like ad-hoc SQL tuning by throwing a bunch of indexes onto a schema), Hibernate could never offer such a feature.
轉(zhuǎn)自: http://xmkevinchen.javaeye.com/blog/196372
郁悶非常的一個(gè)"BUG",只有把hibernate.hbm2ddl.auto update 改成create才能生成索引
郁悶非常的一個(gè)"BUG",只有把hibernate.hbm2ddl.auto update 改成create才能生成索引