I have a dozen of tables like Product, Category, Customer, Order, ... with not null relationships to one another. I created ORM and right now I am in the middle of tests.
However I find it pretty tedious, because in order to test for example Order entity which has to belong to Customer (namely perform persist operation) I have to create Customer instance as well. Lets go further: because Order cannot exist separately to Product I have to create Product and add it to Order. Product has to be in some Category, and so on. So you can see a chain of mandatory relationships, which makes testing individual entity very difficult.
Natural solution would be to defer constraint check to commit (Oracle):
alter session set constraints=deferred;
However I found a piece of information that Hibernate doesn't care of deferring (support for deferred constraint).
Does it mean, that persistence testing has to be so problematic or I can do it better/different?
I believe that db constraints are sacred, so resigning from them, because hibernate does not support it sounds bad.
Aucun commentaire:
Enregistrer un commentaire