• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

cascade and inverJoinColumn

 
Ranch Hand
Posts: 129
  • 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
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!