Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Does ejb 2.0 force you to use only ejbql

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I HAVE to use ejbql for the finders of my ejb 2.0 entity beans ?
Here is my problem. I am using ejb 2.0 and WSAD 5.0 as development environment.

1) I have a Department bean in the OrgEJB project.
2) I have User and UserDept beans in the UserEJB project
Note:- Department, User and UserDept are also database table names. The UserDept table maps users to departments.
I want to find out all departments of a given user.
i.e a finder off Department EJB(actually Home interface) called findByUserId(int userId)
The SQL I would use is:
SELECT * FROM department d WHERE d.dept_no IN (SELECT ud.dept_no FROM UserDept ud where ud.user_id = ?
How do I write the above SQL command in EJBQL so that my finder can use it ?

Appreciate all the help I can get.
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that there is a many to many relationships b/w
SELECT OBJECT(d) from department d, IN(d.users)as u where u.id = ?1
 
Naveen Sampra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. It's a many to many relationship.
To use the "d.users" part in the above sample EJBQL, you have to setup a CMR between Department and User bean.
What happens when you have the beans in two different EJB containers. How do you do the CMR ?
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What happens when you have the beans in two different EJB containers. How do you do the CMR ?


You cannot use CMR when the entities are in different containers because the CMR works for local interfaces.
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic