• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Question about ejbFind

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, from specs 10.7.3 there should be an ejbFind<METHOD> for each find<METHOD> in the bean's home interface. Am I right by supposing that all the ejbFind<METHOD> methods will be only in the Deployment Descriptor for CMP entity beans?
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. We do not implement ejbFind<Method>s in a CMP entity bean (Not even empty methods!).
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct in that the find methods are defined only in the deployment descriptor. I have an example below:

*******************************************
HOME INTERFACE:

package demo.coolservlets.card;

import javax.ejb.*;
import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Date;

public interface PostcardHome extends EJBHome {

public Postcard create() throws CreateException, RemoteException;
public Postcard create(String toEmail, String fromEmail) throws CreateException, RemoteException;

public Postcard findByPrimaryKey(String primarykey)
throws FinderException, RemoteException;

public Collection findExpiredPostcards(Date extime)
throws FinderException, RemoteException;

public Collection findPostcardsByToEmail(String aToEmail) throws FinderException, RemoteException;
}

*******************************
DEPLOYMENT DESCRIPTOR:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>PostcardHome</ejb-name>
<home>demo.coolservlets.card.PostcardHome</home>
<remote>demo.coolservlets.card.Postcard</remote>
<ejb-class>demo.coolservlets.card.PostcardBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>PostcardHome</abstract-schema-name>
<cmp-field>
<field-name>toName</field-name>
</cmp-field>
<cmp-field>
<field-name>imageName</field-name>
</cmp-field>
<cmp-field>
<field-name>fromEmail</field-name>
</cmp-field>
<cmp-field>
<field-name>fromName</field-name>
</cmp-field>
<cmp-field>
<field-name>message</field-name>
</cmp-field>
<cmp-field>
<field-name>creationDate</field-name>
</cmp-field>
<cmp-field>
<field-name>toEmail</field-name>
</cmp-field>
<cmp-field>
<field-name>title</field-name>
</cmp-field>
<cmp-field>
<field-name>key</field-name>
</cmp-field>
<primkey-field>key</primkey-field>
<query>
<query-method>
<method-name>findExpiredPostcards</method-name>
<method-params>
<method-param>java.util.Date</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT DISTINCT OBJECT(o) FROM PostcardHome AS o WHERE (?1 > o.creationDate)</ejb-ql>
</query>
<query>
<query-method>
<method-name>findPostcardsByToEmail</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT OBJECT(o) FROM PostcardHome AS o WHERE (?1 = o.toEmail)</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>PostcardHome</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic