Thanks for you reply. I was not attempting to create an entity bean for a non-updatable entity. What I was trying to do was 'Home business method' whose purpose in case of CMP, according to the Spec, is to make batch select operations possible and to return a sigle or collection of non-ejb type values(as opposed to findBy methods). Now it happens that the select operation that I am attempting requires GROUP BY and HAVING clause. TitleAuthor table is an updatable relationship table with two unidirectional One-Many relationships with tables Title and Author. To figure out titles with multiple authors, I need to execute the following query.
select t.title_id, t.title, t.price, t.pubdate, a.au_id,a.au_fname,a.au_lname, ta.royaltyper
from Title t, (
from TitleAuthor ta,
from TitleAuthor ta
group by ta.title_id
having count(ta.title_id) > 1
where ta.title_id = tb.title_id
) ta, Author a
where t.title_id = ta.title_id
and a.au_id = ta.au_id
order by t.title_id
There is no way I can do this query with EJB-QL.
However, in theory, I should not say that it is impossible to do this in CMP, but I would have to grab all the entities of TitleAuthor table and then perform the above logic programmatically in Java
. Which is practically inefficient and would be asinine of me to do so.
In such scenarios looks like BMP, or if allowed to use Entity beans at all, DAO/JDBC would more efficient.