-
1. Re: writing your own finders in CMP Bean
sheikh Mar 20, 2002 11:24 AM (in response to sheikh)I forgot to mention one thing, that there is a reason for not using jaws.xml as the querry is very complex and these fields are not even in the table of the bean..
regards
Imran -
2. Re: writing your own finders in BMP Entity Bean
shailesh_dangi Mar 20, 2002 11:41 AM (in response to sheikh)--JBoss 3.0 + Tomcat 4.0 on NT--
I ran into a similar problem for an entity bean with BMP.
The findByPrimaryKey works fine. But with custom finder methods the bean implementation is not even called.
Here are sample snippets of the code:
public interface FwkTabHome extends EJBHome {
public FwkTab create(Integer pkId, Integer orgId) throws RemoteException, CreateException;
//This works fine
public FwkTab findByPrimaryKey(FwkTabPK primaryKey) throws FinderException, RemoteException;
//This doesn't
public Collection findByAllAncestors(FwkTabPK primaryKey) throws FinderException, RemoteException;
}
Section of FwkBean
.
.
public Collection ejbFindByAllAncestors(FwkTabPK primaryKey) throws FinderException, RemoteException{
PreparedStatement ps = null;
ResultSet rs = null;
Connection conn = null;
Vector v = new Vector();
try{
conn = this.getConnection();
//This statement is not even printed in the log
System.out.println("Connection in ejbFindAllAncestors :" + conn.getMetaData().getDriverName());
if (conn != null)
ps = conn.prepareStatement(" select ftb_tab_id from fwk_tabs "+
" start with ftb_tab_id = ? "+
" and org_id = ? " +
" connect by prior ftb_parent_id = ftb_tab_id " +
" and org_id = ? " +
" order by ftb_level asc");
if (ps != null){
ps.setInt(1,primaryKey.getFtbTabId().intValue());
ps.setInt(2,primaryKey.getOrgId().intValue());
rs = ps.executeQuery();
}
if (rs == null)
throw new EJBException("Error extracting resultset in ejbFindAllAncestors");
while(rs.next()){
FwkTabPK pk = new FwkTabPK((Integer)rs.getObject("ftb_tab_id"), primaryKey.getOrgId());
System.out.println("Object added: " + pk.toString());
v.addElement(pk);
}
}catch(java.sql.SQLException sqlEx){
throw new EJBException("Error in finder method", sqlEx);
}finally{
try{
if (rs != null)
rs.close();
if (ps != null)
ps.close();
if (conn != null)
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
return v;
}
.
.
.
Do I have to add this custom finder method in some property file for JBoss to pick up?
Moreover, while deploying, the deployment tool (autodeployer??) DOESNOT complain if find method in home interface throws different exceptions from the ejbFind method in the entity bean class. Shouldn't that be checked at the time of deployment also?
Thanks -
3. Re: writing your own finders in CMP Bean
enigma69 Jul 18, 2002 4:01 AM (in response to sheikh)I have exactly the same problem, I use JBoss 2.4.4, is there already a solution?
-
4. Re: writing your own finders in CMP Bean
enigma69 Jul 18, 2002 4:02 AM (in response to sheikh)I have exactly the same problem, I use JBoss 2.4.4, is there already a solution?
-
5. Re: writing your own finders in CMP Bean
naxius Jul 19, 2002 12:48 PM (in response to sheikh)Hi,
You do not have to give any implementation for
your finders in case of CMP bean.
You just have to provide the signature in the Home of your
CMP and, in the DD, just write your EJB-QL that
represents your query.
Hope this helps.
Regards,
Alexandre