Can I map more than one table in a CMP?

Alessandro A. Garbagnati

Actually the answer is no, you cannot map more than one table to a single CMP Entity Bean. CMP has been, in fact, designed to map a single table.

Said so, we can see that there could be some workaraounds.
The easiest one is to create a VIEW on the database side and have your CMP Entity mapped to it.
This is a perfect fit for a read-only solution and, since views are not database dependant, this is a portable solution.

Personally, I think that considering the way database work, it should be possible to use not-read-only ejbs with views. The trick, probably, is to include all the fields from all the tables (including the pk of all tables) and create a compound PK object that maps to all the PKs of the tables.
I haven't tested that but if anybody is interested in "wasting" some time, it would be nice...

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact