Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Query on JPA Annotation

 
Ranch Hand
Posts: 763
  • 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

 
author and cow tipper
Posts: 5000
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: 763
  • 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
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic