CHAPTER 8 Legacy databases and custom SQL type=”timestamp” index=”IDX_END_DATE”/> The automatically produced DDL now includes an additional statement: create index IDX_END_DATE on ITEM (END_DATE); The same functionality is available with annotations, as a Hibernate extension: @Column(name = “END_DATE”, nullable = false, updatable = false) @org.hibernate.annotations.Index(name = “IDX_END_DATE”) private Date endDate; You can create a multicolumn index by setting the same identifier on several property (or column) mappings. Any other index option, such as UNIQUE INDEX (which creates an additional multirow table-level constraint), the indexing method (common are btree, hash, and binary), and any storage clause (for example, to create the index in a separate tablespace) can be set only in completely custom DDL with . A multicolumn index with annotations is defined at the entity level, with a custom Hibernate annotation that applies additional attributes to table mapping: @Entity @Table(name=”ITEMS”) @org.hibernate.annotations.Table( appliesTo = “ITEMS”, indexes = @org.hibernate.annotations.Index( name = “IDX_INITIAL_PRICE”, columnNames = { “INITIAL_PRICE”, “INITIAL_PRICE_CURRENCY” } ) ) public class Item { … } Note that @org.hibernate.annotations.Table isn t a replacement for @javax. perisistence.Table, so if you need to override the default table name, you still need the regular @Table. We recommend that you get the excellent book SQL Tuning by Dan Tow (Tow, 2003) if you want to learn efficient database-optimization techniques and especially how indexes can get you closer to the best-performing execution plan for your queries. One mapping we have shown a few times in this chapter is . It has some other options that we haven t discussed yet. 8.3.7 Adding auxiliary DDL Hibernate creates the basic DDL for your tables and constraints automatically; it even creates sequences if you have a particular identifier generator. However,
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.
This entry was posted
on Monday, March 17th, 2008 at 1:13 pm and is filed under PHP5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.