Hibernate SchemaUpdate建立索引问题

当hibernate的hbm2dll配置为 
  1. hibernate.hbm2ddl.auto update  
将会发现Hibernate不会为我们创建任何自定义的索引(不包括主键跟外键索引),不论你使用xml方式或者annotation进行声明配置 
这个问题在Hibernate的JIRA多次出现,甚至有人专门为此发布了打了补丁的hibernate.jar 
这个所谓的bug,在目前已发布的hibernate的版本中,一直都没有解决,或者说不予理睬(Gavin King个人认为这个不是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. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值