• 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

cascade and inverJoinColumn

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I have the following tablessince employee and award are many-to-many relation we have

If we have


Questions:

1. If we  DON'T  specify "Cascade" in many-to-many mapping or configuration file, then when we do session.save(employee), is it true it will only save "employee" data into Employee table, and will NOT save the associated "award" data into Award table ?  How about the "EMployee_AWARD" link table ?

2. Confusion about "inverseJoinColumn", two things:

     if we set "inverseJoinColumn" as follows:

     a)  If this is a uni-directional relation, i.e. we only include "Award" in Employee class (but don't include Employee in Award class), then do we need to specify this "inverseJoinColumn" in Employee class ?

      b) If we have a bidirectional bahavior, i.e. we let "Employee" and "Award" classes include each other (<Set>) as class attributes, then we need to specify "inverseJoinColumn" anyway, correct ?

      Overall, I am just confused when this "inverseJoinColumn" is needed and not needed...
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Linwood Hayes wrote:Overall, I am just confused when this "inverseJoinColumn" is needed and not needed...


Did you already check the Java Persistence API WikiBook? When I'm having an issue with JPA, JPQL, or something related it's the first resource I'll check to find a solution. It's really an excellent resource (in my humble opinion)! It's not a step-by-step tutorial, but you'll find everything required in this wiki book with illustrative code snippets and very good explanations: from basic entity mappings to complex JPQL queries. Here is the section about the ManyToMany relationship.

Hope it helps!
Kind regards,
Roel
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic