Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can 1 Entity bean be written for 2 different tables

 
Sachin Paradkar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can 1 Entity bean be written for 2 different tables in EJB 2.0 or 3.0 .

Regards,
Sachin Paradkar.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 Entity bean can only be referred to 1 single table, or a set of joined tables. You have to specify which table you are referring.

It is impossible for 1 Entity bean be referred to 2 tables that are not joined even they have the same schema.

Nick
 
Vicky Bajaj
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by Set of tables ?

In Entity Bean, we define abstract schema for an Entity bean. how do you define abstract schema for set of tables
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vicky,

I think what Nick meant by "set of joined tables" is a "view" - right Nick?


-Saeed
[ July 27, 2005: Message edited by: Saeed Amer ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean is, for example as specified in HF EJB page 375, we might have 3 tables: Movie, Director and Trailer. They are 3 seperated tables, however, you might want to see all movies with directors who are o more than 3 degrees away from "Kevin Bacon" and the genre is "romantic horror".

Definitely you can see that if you want to satisify such requirement, you have to "join" the tables, and 1 entity bean represents a row of a joined table. That's why I meant.

One entity bean can only map to 1 table, however, by making use of CMR, that entity can also retrieve records from other tables (see HF EJB page 396-397), and you have to specify the <ejb-relation> in the <relationships> element in DD.

Nick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic