Win a copy of Microservices Testing (Live Project) this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

many to many jpa saving example

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,
I was able to do the jpa many to many example ( http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=19mappingmanytomanyrelationships )

Thanks Cameron for the same .

However I am totally confused regarding how I should go about doing the same when I have an extra column in the Join Table

I know I would need to create a new Java Object for this join table

As an example ( Emp , Address , EmpAddress as three tables and Java Objects )

Should the Emp to Address & Address to Emp be mapped as a One to Many ?
Should the EmpAddress bean contain a Set for both Emp & Address and have this as a ManyToOne association ?

Thanks,
~satish
[ July 11, 2008: Message edited by: satish bodas ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, and this doesn't mean that it is the best way, but I like to create the new object, and just have the two Many to Ones on both sides>

But the ManyToMany still works with more annotations/mappings.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic