Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • 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

Hibernate Beginner Questions

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner in using the Hibernate. I have three questions need help:

1. How to index a key that is a combination of multiple table fields?

2. How does the Hibernate handle many-to-many relation?

3. What to do if a table field is read-only so that the field does not get updated?

Thank you very much in advance.
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My reply here will be very brief. So I'll leave more explanation to you as an exercise


1. How to index a key that is a combination of multiple table fields?


Use @Embaddable and @EmbaddableId for composite keys.


2. How does the Hibernate handle many-to-many relation?


Hibernate will create an association table with many-to-many entity associtation, i.e. @ManyToMany with @JoinTable.


3. What to do if a table field is read-only so that the field does not get updated?


You can call session.setReadOnly(object, true) to disable dirty checking for a particular instance.

Hope this helps.
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your guidance. It is all I need.
 
Let's get him boys! We'll make him read this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic