CHAPTER 8 Legacy databases and custom SQL required for this declaration, because no attribute supports the SQL datatype on the element. C For decimal types, you can declare the precision and scale. This example creates the column as INIT_PRICE number(10,2) on an Oracle dialect; however, for databases that don t support types with decimal precision, a simple INIT_PRICE numeric (this is in HSQL) is produced. D For the description field, you add DDL attributes on the
element instead of a nested element. The DESCRIPTION column is generated as VARCHAR(4000) a limitation of a variable character field in an Oracle database (in Oracle, it would be VARCHAR2(4000) in the DDL, but the dialect takes care of this). E A element can also be used to declare the foreign key fields in an association mapping. Otherwise, the columns of your association table CATEGORY_ITEM would be VARCHAR(32) instead of the more appropriate CHAR(32) type. The same customization is possible in annotations, see listing 8.2. Listing 8.2 Additional annotations for customization of DDL export @Entity @Table(name = “ITEMS”) public class Item { @Id @Column(name = “ITEM_ID”, columnDefinition = “char(32)”) @GeneratedValue(generator = “hibernate-uuid.hex”) @org.hibernate.annotations.GenericGenerator( name = “hibernate-uuid.hex”, strategy = “uuid.hex” ) Private String id; @Column(name = “INIT_PRICE”, nullable = false, precision = 10, scale = 2) BigDecimal initialPrice; @Column(name = “ITM_DESCRIPTION”, length = 4000) Private String description; @ManyToMany @JoinTable( name = “CATEGORY_ITEM”, joinColumns = { @JoinColumn(name = “ITEM_ID”, columnDefinition = “char(32)”) }, inverseJoinColumns =
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.
This entry was posted
on Wednesday, March 12th, 2008 at 10:28 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.