Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can CMP be used...................  RSS feed

 
monojit choudhury
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have a problem.the software i m working on,requires a single entity bean connect to 5 different databases.i know this can be done thru BMP.but is there any other solution.i mean can this be done thru CMP also?
thanks in adv
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A related question....
If I am able to write a stored procedure that can join multiple tables, apply some business logic and return appropriate result set, can i refer to that stored procedure using EQL?
thanks,
Jim.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer the first question:
The specification says that entity beans should be coarse-grained objects so they should not necessarily have a 1:1 relationship with rows in a single table. CMP can handle what you want to do.
The second question:
EJB QL does not support invoking of stored procedures.
 
monojit choudhury
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i got that,but when i want to connect to 5 different databases(lets say one using oracle,one using SQLServer,etc)i cant do that in a single Deployment descriptor or can i? According to my knowledge a single DD can hold the information about a single database.
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a related question:
Can CMP of EJB 2.0 can do Object/Relation mapping ?
I am getting used to an approach to build a data model first with relational DB. Then to build a J2EE application on top of the data model. Therefore I face to a mapping problem. I can do it with BMP. However, how can I do it with CMP of EJB 2.0.
EJB 1.1 can not do it.
Thanks
Ruilin
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Tom.
Ruilin, functionalitywise, EQL is pretty much same as SQL. I don't think you can do OR mapping with it.
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim, That helps.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by monojit choudhury:
ya i got that,but when i want to connect to 5 different databases(lets say one using oracle,one using SQLServer,etc)i cant do that in a single Deployment descriptor or can i? According to my knowledge a single DD can hold the information about a single database.

I misuderstood your question. If you want to go against different databases to create one entity bean then you can't use CMP.

------------------
Tom
Sun Certified Programmer for the Java� 2 Platform
Moderator of the forums:
J2EE and EJB
Other Java APIs
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ruilin yang:
a related question:
Can CMP of EJB 2.0 can do Object/Relation mapping ?
Yes. EJB 2.0 supports the creation of entity relationships using CMP. Chapter 7 of Enterprise JavaBeans - Third Edition covers this topic very well.

[This message has been edited by Thomas Paul (edited December 05, 2001).]
 
monojit choudhury
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
thanks for ur replies,i really appreciate that.
well.......i think i got an answer.please let me know if this will work.there are 2 solutions for this.
1) we can create diffrent jndi names for each Database type.lets say we wanna use 5 diffrent databases.so we'll have 5 diffrent jndi names.so as a result of this we'll have 5 entity cmp beans .well instead of a single entity bean,we've got 5 beans.this i dont think will be a problem as long as the container ddoent mind storing those.i've checked it out,n found that the container doesnt have any probs doing that.SO each entity bean will connect to a specific database.
2)another solution might be,to bypass the container.i think using the API exposed by weblogic this can be done.but i m not sure how to go about it.can anyone give any ideas as how this can be done?
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Paul:
Yes. EJB 2.0 supports the creation of entity relationships using CMP.

I beg to differ here. OR mapping is not same as specifying Entity relationships. For example, you have an Order Object which has multiple OrderLine objects. Now, the relationship between the two objects can be handled by the EJB container. But you still need to have relational database tables structured that correspond directly to the objects.
On the other hand, if you already have a legacy system which (say) has one table that includes columns for Order as well as OrderLine objects, I'm not sure the EJB container will be able to handle it. The situation could be much more complex.
So, the point I am trying to make here is OR mapping and Entity relationships are two different things.
Please correct me if I am wrong.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Bertorelli:
I beg to differ here. OR mapping is not same as specifying Entity relationships. For example, you have an Order Object which has multiple OrderLine objects. Now, the relationship between the two objects can be handled by the EJB container. But you still need to have relational database tables structured that correspond directly to the objects.

There is no need for direct correspondence between entity beans and rows in a database. For example, I could have an entity bean that contains customer purchase history info and another entity bean that represents customer address info. In my database these could be in the same table! In fact, the recommendation is that entity beans should NOT directly correspond to DB tables. Entity beans are supposed to represent coarse-grained business information. The only requirement is that the entity beans with a realtionship must be in a single deployment unit which means they must use the same database. In the future it is likely that this constraint will be removed.
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I see what you are saying.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!