• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP to Map multiple tables

 
Bondu Sam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the database in my project has been fully normalised. I am using CMPs for database operations. BEcause of teh normalisation i have far too many tables, and i am scared that the performance of the system will be affected with increase in number of tables. I want to map one entity bean to multiple tables. is this possible using CMP1.1 on websphere 4.0.1?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
The JavaRanch police will be after you -- because of your (unacceptable) login name (but don't say I didn't warn you ;-)
By CMP1.1, I assume you mean that you are using CMP entity EJBs that comply with the EJB specification (from SUN Microsystems), version 1.1, correct?
If yes, then obviously you cannot use CMR (Container Managed Relationships) -- which was introduced with version 2.0 of the specification.
One possibility may be to create a database view on several database tables (assuming your DBMS supports it -- I don't know, since I didn't see any details, in your post, about which DBMS you are using). Then you create a CMP entity bean on the view!
I don't know if this is relevant, but there is an article in the June, 2001 edition of (the now defunct) Java Report magazine entitled, "Entity Bean Relationships in EJB 1.1" by Grant Holland.
[Unfortunately, I don't think it is available online.]
Hope this helps you.
Good Luck,
Avi.
 
Bondu Sam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks avi
i am using oracle 8.1.7, i thought using cmp on views was a part of ejb 2.0 specs. Could u plss give more details about how this could be achieved
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sam",
Thanks for joining JavaRanch, but could you just take a quick look at the naming policy and edit your profile.
Thanks
Simon
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
Unfortunately, there's only one circumstance under which WebSphere 4.0's CMP support allows you to map > 1 table to a single EJB -- that's where the tables share a primary key. Also, I'm sorry to disappoint you about Avi's suggestion, but you can't map a CMP to a View in WebSphere either.
However, unlike what Avi said, we do support the equivalent of CMR in WebSphere 4.0 -- they're called EJB relationships. But that won't help you cut down the number of CMP EJB's in your application -- each CMP still maps to one table; but the generated code handles foreign key traversals the same way it's handled in EJB 2.0.
So how many tables are you talking about? You might be surprised at how well WebSphere 4.0 can do even with mapping each EJB to one table. If the number of tables is under 100, quite honestly this can probably be managed. If it's > 100 then you might have a problem (compile and rebuild times being an issue).
Also, remember that's it's perfectly fine to mix CMP's and DAO's in the same program -- so you might model part of your solution with CMP's, and part as Value Objects simply using DAO's.
Hope this helps.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic