Improving schema DDL If you want to create a unique constraint with annotations that spans several columns, you need to declare it on the entity, not on a single column: @Entity @Table(name = “CATEGORY”, uniqueConstraints = { @UniqueConstraint(columnNames = {”CAT_NAME”, “PARENT_CATEGORY_ID”} ) } ) public class Category { … } With JPA XML descriptors, multicolumn constraints are as follows:
CAT_NAME PARENT_CATEGORY_ID
… Completely custom constraints, including an identifier for the database catalog, can be added to your DDL with the element: alter table CATEGORY add constraint UNIQUE_SIBLINGS unique (CAT_NAME, PARENT_CATEGORY_ID); drop constraint UNIQUE_SIBLINGS This functionality isn t available in annotations. Note that you can add a Hibernate XML metadata file with all your custom database DDL objects in your annotation- based application. Finally, the last category of constraints includes database-wide rules that span several tables. 8.3.5 Database constraints You can create a rule that spans several tables with a join in a subselect in any check expression. Instead of referring only to the table on which the constraint is declared, you may query (usually for the existence or nonexistence of a particular piece of information) a different table.
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.
This entry was posted
on Sunday, March 16th, 2008 at 5:16 am 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.