TRANSACTION >-----PURCHASE-----< PURCHASE_MODULE
First thing, How do I represent that using annotations (Hibernate):
Now what I want is each time I populate Purchase and set both List's (transactions and purchaseModules) and Invoke a SAVE for Purchase, the 3 tables will be impacted( there will be at least 3 INSERTs): purchaseDAO.save(purchase)
But this wasn't working as I expected, because no matter if I populated both ArrayList's (List) I never saw more than 1 Insert on my console.
Then the spark I was looking for! Inspiration came to me :P
On the Annotation @OneToMany there is an additional attribute I didn't include: cascade (The operations that must be cascaded to the target of the association)
On my case I don't care, so I just include ALL operations :P
No comments:
Post a Comment