Hi

Two things actually. No three. Firstly, I'm not using JBoss, I'm using
Sun's thing, but I think my question is generic.

Second, how do you ppl get the whole [beginners corner] prefix to your
messages? The
<https://lists.sourceforge.net/lists/listinfo/jboss-user> site says
nothing about that, it just says post to
[EMAIL PROTECTED] I added my own prefix but its
consistency says there's more to it than that.

OK, on to my question. I can't seem to find an example of a working
CMP entity bean that uses a String as its primary key, and I'm getting
errors I can't fix. This will be my first entity bean, so I guess I
may have missed something, but I can't tell you how many books and
examples I've worked through, and how much work has gone into learning
this so far. It's all pretty simple, but it doesnae work.

I'm getting the following failures:
For [ RegistrantBean ]
For EJB Class [ RegistrantBean ] ejbCreate(...) method [ ejbRemove ]
Error: An ejbCreate(...) method was found, but did not properly return
the primary key class type.

For [ RegistrantBean ]
For Home interface [ RegistrantHome ]
Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was
found in home interface class [ RegistrantHome ].

For [ RegistrantBean ]
Error: [ RegistrantBean ] does not properly implement the EntityBean
interface.  All entity beans must implement the EntityBean interface. 
[ RegistrantBean ] is not a valid bean.

For [ RegistrantBean ]
Error: [ RegistrantBean ] is not a valid bean. The bean provider must
use the appropriate session or entity element to declare the bean
type.

If you want it, here's my code:
Remote interface:
import java.rmi.RemoteException;
import javax.ejb.*;

public interface Registrant extends EJBObject
{
        public String getEmail() throws RemoteException;
        public String getPassword() throws RemoteException;
        public String getFirstName() throws RemoteException;
        // notes say set methods aren't exposed to the public
        //public void setEmail(String pEmail) throws RemoteException;
        //public void setPassword(String pPassword) throws RemoteException;
        //public void setFirstName(String pFirstName) throws RemoteException;

}

Home interface:
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;

public interface RegistrantHome extends javax.ejb.EJBHome
{
        // creates and initialises a bean instance
        public Registrant create (String email, String password, String
pFirstName) throws CreateException, RemoteException;

        public Registrant findByPrimaryKey (Registrant registrant) throws
FinderException, RemoteException;
}


Bean:
import javax.ejb.*;

public abstract class RegistrantBean implements EntityBean
{

        public Registrant ejbCreate(String pEmail, String pPassword, String
pFirstName) throws CreateException
        {
                setEmail(pEmail);
                setPassword(pPassword);
                setFirstName(pFirstName);
                return null;
        }

        public void ejbPostCreate(String pEmail, String pPassword, String
pFirstName) {}

        // CMP fields
        public abstract String getEmail();
        public abstract void setEmail(String pEmail);
        public abstract String getPassword();
        public abstract void setPassword(String pPassword);
        public abstract String getFirstName();
        public abstract void setFirstName(String pFirstName);

        public void ejbActivate() {}
        public void ejbPassivate() {}
        public void ejbLoad() {}
        public void ejbStore() {}
        public void ejbRemove() {}

        private EntityContext ctx;

        public void setEntityContext(EntityContext ctx)
        {
                this.ctx = ctx;
        }

        public void unsetEntityContext()
        {
                this.ctx = null;
        }
}


All ideas welcome.

J


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to