• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use EJB-Relationships??  RSS feed

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am developing EJB's for my Web Application. I am using PostgreSQL 8.0 as Database. In My database there is already reletionship defined between table. My question is that still there is necesity of define relationship between EJB's? as realtionship is already defined in database between tables.
I have successfully defined relationships between EJB's in my Beans Code.
If answer of my above question is "yes" then how to utilize the relationship? & also please tell me what is use of EJB relationship if there is already relationship defined between tables in my database.

Thanx in Advance.

Prash.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The relationship you defined in DB is for database objects and is used for data consistency and is purely relational model. However you still need to define the relationship in EJB (ORM). By defining relationship in EJB you ensure all the related data is loaded/inserted/updated when an object with dependency is loaded/updated/inserted.

Say for example you have two tables
Employee and Department
when you read the details of Employee you can also read the details of the department associated with the employee. For more information you can look into Mastering EJB by Ed Roman or any other EJB book.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!