Entity Bean Problem
1 posts in topic
Flat View  Flat View

Posted By:   saddy_san
Posted On:   Sunday, December 29, 2002 08:54 PM

Hello Friends,
I am new to ejb, i have read that entity beans are view to the database and in ejb we dont deal with database directly rather we deal with entity beans.
My problem is if i want to find out all the employees who have salary greater than 5000(or any such query) how am i going to do this in entity beans.
plz help

Re: Entity Bean Problem

Posted By:   Itoyjaved_C  
Posted On:   Monday, December 30, 2002 04:35 AM

Hi Sanny,
First you will have to determine whether you will be using a container managed persistence (CMP) or bean managed persistence (BMP).

In case if you are using BMP, then you can add a finder method method and pass the amount as a parameter in that method in home interface. While in the bean impl class you can write a proper sql query that will return collection of remote interfaces.

While if you use CMP then you will have to mention the finder method in the home interface. As in CMP the container constructs proper data retrieval query, you will just need to mention the kind of query using ejbQL(if u are using ejb2.0)in the ejbjar.xml. So for ur kind of query the query format would look like:-

FROM User user
WHERE user.userInfo.salary > ?1

For better understanding you can have a look into the EJBQL details about the kind of query it supports with the declaration struction in ejb_jar.xml.

Hope this answers your query to a good extent.
About | Sitemap | Contact