This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
If my assumption is correct, Hibernate is more on transactions and Data Manipulation and not in the Date Definition. I would like to know
How can i add constraints to table with Hibernate?
The two ways that strikes my mind is
a. In the setter method of the pojo class, add the constraint. But i need to know if this will work well in all the case.
b. using native sql, alter the table and add the constraint.
Please let me know which is correct way to add the constraint in the table.
There are a variety of annotations that impact how SQL is generated. Just some of the annotations for a Column are as follows:
Now those are just JPA specific. Hibernate has extensions that go beyond the JPA specification as well. You'd have to research a bit deeper to find out how granular the types of constraints on columns and tables can be.
Joined: Jul 08, 2008
Did you mean that I can add/represent constraint like check in the mappings of the entity.