CHAPTER 8 Legacy databases and custom (Web hosting mysql) SQL Another

CHAPTER 8 Legacy databases and custom SQL Another technique to create a database-wide constraint uses custom triggers that run on insertion or update of rows in particular tables. This is a procedural approach that has the already-mentioned disadvantages but is inherently flexible. By far the most common rules that span several tables are referential integrity rules. They re widely known as foreign keys, which are a combination of two things: a key value copy from a related row and a constraint that guarantees that the referenced value exists. Hibernate creates foreign key constraints automatically for all foreign key columns in association mappings. If you check the DDL produced by Hibernate, you may notice that these constraints also have automatically generated database identifiers names that aren t easy to read and that make debugging more difficult: alter table ITEM add constraint FK1FF7F1F09FA3CB90 foreign key (SELLER_ID) references USERS; This DDL declares the foreign key constraint for the SELLER_ID column in the ITEM table. It references the primary key column of the USERS table. You can customize the name of the constraint in the mapping of the Item class with the foreign-key attribute: With annotations, use a Hibernate extension: @ManyToOne @JoinColumn(name = “SELLER_ID”) @org.hibernate.annotations.ForeignKey(name = “FK_SELLER_ID”) private User seller; And a special syntax is required for foreign keys created for a many-to-many association: @ManyToMany @JoinTable(…) @org.hibernate.annotations.ForeignKey( name = “FK_CATEGORY_ID”, inverseName = “FK_ITEM_ID” ) private Set categories… If you want to automatically generate DDL that isn t distinguishable from what a human DBA would write, customize all your foreign key constraints in all your mapping metadata. Not only is this good practice, but it also helps significantly
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.