Kai Schmidt (1) [Avatar] Offline
In chapter 9.1.2 there is an example for a database constraint spanning over multiple tables:

alter table BID
add constraint AUCTION_BID_TIME
check(CREATEDON <= (select i.AUCTIONEND from ITEM i where i.ID = ITEM_ID));

As I found out now mySQL doesn't support check constraints at all. PostgreSQL and SQL Server doesn't support selects within a check constraints. Also as far as I know from Oracle database check constraints are only row based. The "manual" workaround for mySQL and PostgreSQL seems to be the use of triggers instead. However, I can't imagine that Hibernate translate such check constraint into a database trigger.

What does Hibernate do with such a statement and with which DBMS is this working?

P.S.: Thanks a lot for your great book. Although I'm using Hibernate for several years now, I learned a lot and the book it's structured very well. It's a really good reference.