Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic