java - Delete Entity With JPA -


i couldn't delete entitys db. have 2 class 1 of them receipt , other serving. receipt has

    @elementcollection @onetomany(cascade={cascadetype.all}, orphanremoval=true) public list<serving> servings; 

and i'm tring delete serving controller.

serving serving = serving.findbyid(servid); serving.delete(); 

the result is;

execution exception persistenceexception occured : org.hibernate.exception.constraintviolationexception: not execute jdbc batch update

something like:

receipt receipt = serving.getreceipt(); receipet.setservings(receipt.getservings().remove(serving)); 

since receipt oo owner of servings, oo perspective receipt must know when serving deleted.

maybe write finder on receipt either serving or servingid.

(are sure servings shouldn't know receipt belongs to? - orphanremoval seems indicate serving belongs 1 , 1 receipt)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -