cancel
Showing results for 
Search instead for 
Did you mean: 

How to return a full DB table in EJB

Former Member
0 Kudos

Hi all,

I have a container-managed bean referring to a small table. In this bean I have defined some lookup methods such as findByType(String type). In my session EJB however, I want to get a list of all the records from this table. Can anyone tell me how I can do this?

Thanks a lot!

Regards,

Hart

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

In persist.xml, I can use a SQL statement instead of EJB-QL statement. This is the only way I can think of.

It'll be appreciated if anyone has better ideas.

Regards,

Hart

Former Member
0 Kudos

Hi,

why not specifying a public Collection findAll() throws FinderException within your Home-Interface ?

You have to declare within ejb-jar.xml as well; sth. like

<entity>

...

<abstract-schema-name>

xyzASN

<abstract-schema-name>

...

<query>

<query-method>

<method-name>

findAll

</method-name>

<method-params/>

</query-method>

<ejb-ql>

SELECT OBJ(o) FROM xyzASN AS o

<ejb-ql>

</query>

...

</entity>

AFAIK you could specify this within NWDS as well but I don't remember how.

Anyway, you get a Collection of Remote/Local component interfaces this way which you could iterate through.

Regards

Matthias

Former Member
0 Kudos

Yes, you are right. I can add the EJB QL statement in ejb-jar.xml.

Using NWDS, you can open that file, and go to tab Enterprise Beans. Under the bean query, you can enter the EJB QL statement.

Thanks a lot for your help!

Hart

Former Member
0 Kudos

Sorry, forgot to mention that the exact EJB QL statement is:

SELECT object(a) FROM ejbbean a