• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Delete query also getting called along with select query on user entity

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am observing that delete query on user_skills table is also getting called along with user select query.
Actually there are two entities User and Skill. There is a ManyToMany relationship between these two entities with a join table USER_SKILLS. Below are the class defintions:





I was able to save User with  many skills into database and when I try to get the saved user info from database then delete query on user_skills table is also getting fired and the data is getting deleted from user_skills table. Below is the queries log:

Hibernate:
   User table query: select this_.id as id1_2_0_,this_.first_name as first_na8_2_0_,this_.last_name as last_na11_2_0_ from user user0_  where user0_.id=?
   
   User_Skills table query: select userskills0_.id as id1_2_0_,userskills0_.skill_id as skill_id2_4_0_,skill1_.skill_id as skill_id1_0_1_,skill1_.name as name2_0_1_  from  user_skills userskills0_ inner join skill skill1_ on userskills0_.skill_id=skill1_.skill_id
                                          where userskills0_.id=?


   User_Skills delete query: delete from user_skills where id=?

Why this delete query is getting called I am not getting? Is this expected in hibernate? Can some one please help me on this?
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic