Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on JPA Annotation

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two Hibernate Persistant class.

Customer and Product

which are as bellow

Customer.java


Product.java



Now in database i am already haveing 1 customer and 3 product for that customer

now when i load customer object from database and remove one product for that customer.

and then again saves the customer object in database is it possible to remove the product for that database without using sesison.delete(..) method. ?

Bellow is my test class and output on console

so that you will get clear understanding ...

Test,java



Console output



There is only an insert query for the new module Reports. but no detele query for removing Campaign Manager module

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to try and change the CASCADE TYPE to MERGE.

-Cameron McKenzie
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i changed to CascadeType.MERGE but it neither deleted any record nor it inserted any record.

i will try to Analise hibernate log file.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic