• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubts in EJB

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the following two questions regarding Enterprise Beans.

1. Can an Entity Bean map to two tables in the database. If yes, how can it be done.
2. Can we have a 'synchronized' method in an Enterprise bean. Reasons for both the answers ('yes' and 'no').
Waiting for answers,
Thanks.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answers to your questions are
(1) YES
(2) YES
You were asked to say YES or NO
Bye
 
Smita Kulkarni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was funny but I had asked for the reasons for the answer. Jokes apart, I would be grateful if you give me the explanation for your answer.
Thanks.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is possible to have a synchronized method in an ejb, but it might not be a good idea ... one of the ideas behind ejbs is that low level things (like threading) should be handled by the container and if you start coding them yourself, it may interfere with what the container is doing.
There was an article in javaworld on what you can but shouldnt do in ejbs, and that was one of the things they mentioned.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can answer just one...
Sure, you can have synchronized methods in your EJB. Not that it makes any difference. The container will not allow more than a single thread to access your EJB object anyway, and you may not spawn your own threads that might do this.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to your first question is Yes.
This is made possible with using BMP(Bean-Managed Persistent) Entity Beans.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For accessing more that two tables you could use view in database which combine two tables ..
Else u could use tool like TOPLINK which writes teh complex queries ..

Regards,
srini
YOu could contact me in srinivas_an_2000 if it is too immediate..
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with bmp you can have any number of tables in one entity bean.
you can use stored procedure or table directly to manage persistence
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Smita Kulkarni:
[B]Hi,
I have the following two questions regarding Enterprise Beans.

1. Can an Entity Bean map to two tables in the database. If yes, how can it be done.
>> With CMP u can't do it directly except that of using views. The Other way is to use BMP and write ur own implementations for ejbCreate and ejbPostCreate...
Reply me if there is any other way....
2. Can we have a 'synchronized' method in an Enterprise bean. Reasons for both the answers ('yes' and 'no').
>> We can have it but it will directly affect the performance becaz threading is handled completely by Containers of Application server and dont know the way of their handling. And Containers uses single threading model, but still there is a way called reentering the bean.
For more help u can refer orielly's EJB book *3rd or 4th chapter i dont remember exactly...
Chalo bye
Regards.
Badal

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With respect to the synchronization, I would avoid using
it - the EJB 2.0 spec actually forbids it. Check section
23.1.2. Your apps probably will not be forward compatible.
 
Ranch Hand
Posts: 449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sid Vicious,
It's 24.1.2 (Programming restrictions).

Moreover it says
An enterprise Bean must not use thread synchronization primitives to synchronize execution of
multiple instances.
must not is not same as can not.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic