Improving schema DDL END_DATE timestamp not null, … check (START_DATE < END_DATE) ); Table constraints are appended in the CREATE TABLE DDL and can contain arbitrary SQL expressions. You include the constraint expression in your Hibernate mapping file on the mapping element: Note that the < character must be escaped as < in XML. With annotations, you need to add a Hibernate extension annotation to declare check constraints: @Entity @org.hibernate.annotations.Check( constraints = "START_DATE < END_DATE" ) public class Item { ... } Multirow table constraints can be implemented with more complex expressions. You may need a subselect in the expression to do this, which may not be supported in your DBMS check your product documentation first. However, there are common multirow table constraints you can add directly as attributes in Hibernate mappings. For example, you identify the login name of a User as unique in the system:
Unique constraint declaration is also possible in annotation metadata: @Column(name = “USERNAME”, length = 16, nullable = false, unique = true) @org.hibernate.annotations.Check( constraints = “regexp_like(USERNAME,’^[[:alpha:]]+$’)” ) private String username; And, of course, you can do this in JPA XML descriptors (there is no check constraint, however):
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.
This entry was posted
on Saturday, March 15th, 2008 at 4:24 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.