As you know that in ejb there are two ways to set pk class: either the <pk-class/> tag which is a class having some fields of your bean, or a primkey-field which points to a single field. Now if you use ejb:bean's primkey-field then you're telling it you're using approach number two.
In fact my previous guide was misguide. Use either of the two but not both. So if you're using primkey-field then ejbCreate/findPK should return the return type of that field, if using pk-class ejbCreate/findPK should return the pk-class type and mark the field with @ejb:pk-field. Ara. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:xdoclet-user- > [EMAIL PROTECTED]] On Behalf Of Michael Delamere > Sent: Friday, May 10, 2002 11:48 PM > To: Ara Abrahamian; [EMAIL PROTECTED] > Subject: Re: [Xdoclet-user] Error when deploying... > > Hi, > > Thanks for the reply. > > I did as you said (I think) and still got the same error: > > /** > * This is an gbEntry bean. It is an example of how to use the > * EJBDoclet tags. > * > * @see Customer gbEntries are owned by gbUsers, and a gbUser can > * have many gbEntries. > * > * @ejb:bean name="guestbook/gbEntry" > * type="CMP" > * jndi-name="ejb/guestbook/gbEntry" > * primkey-field="entry_id" > * @ejb:finder signature="Collection findAll()" > * unchecked="true" > * @ejb:interface remote-class="com.morelogs.guestbook.interfaces.gbEntry" > =========== added line ================================ > * @ejb:pk class="com.morelogs.guestbook.interfaces.gbEntryPK" > * > * @jboss:table-name gbEntries > * @jboss:data-source-name ejbGuestbookDS > * @jboss:persistence > */ > > Have I maybe placed the new tag in the wrong place? > > Thanks, > > Michael > > > ----- Original Message ----- > From: "Ara Abrahamian" <[EMAIL PROTECTED]> > To: "'Michael Delamere'" <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Friday, May 10, 2002 8:33 PM > Subject: RE: [Xdoclet-user] Error when deploying... > > > > Well, we should make it smarter but.... > > > > Anyway you should also define a @ejb:pk class="full-pk-classname" for > > the ejb. That's because you're using a <prim-key-field/> and if you > > don't put a ejb:pk ejbdoclet tries to use the default name from default > > values of <entitypk/> subtask. > > > > Ara. > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto:xdoclet-user- > > > [EMAIL PROTECTED]] On Behalf Of Michael Delamere > > > Sent: Friday, May 10, 2002 10:41 PM > > > To: [EMAIL PROTECTED] > > > Subject: [Xdoclet-user] Error when deploying... > > > > > > Hi, > > > > > > Everything seems to be working fine until I deploy my EJB-Jar. The > > > problem > > > seems to have something to do with my primary key. I�m not exactly > > sure > > > what I�m doing wrong as I have looked at the examples fairly closely. > > > Could > > > someone possibly point me in the right direction? > > > > > > =============== ERROR =============================== > > > 2002-05-10 19:31:44,908 ERROR [org.jboss.ejb.EjbModule] Initialization > > > failed > > > org.jboss.deployment.DeploymentException: primkey-field must be the > > same > > > type as prim-key-class > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCCMPFieldMetaData.<init>(JDBC > > CM > > > PF > > > ieldMetaData.java:130) > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.<init>(JDBCEn > > ti > > > ty > > > MetaData.java:270) > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(J > > DB > > > CA > > > pplicationMetaData.java:117) > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFi > > le > > > Lo > > > ader.java:52) > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(J > > DB > > > CS > > > toreManager.java:595) > > > at > > > > > org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.create(JDBCStoreManager. > > ja > > > va > > > :322) > > > at > > > > > org.jboss.ejb.plugins.CMPPersistenceManager.create(CMPPersistenceManager > > .j > > > av > > > a:155) > > > at > > org.jboss.ejb.EntityContainer.create(EntityContainer.java:337) > > > at org.jboss.ejb.Container.invoke(Container.java:790) > > > at > > org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055) > > > at > > > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491) > > > at > > > > > org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController > > .j > > > av > > > a:867) > > > at $Proxy0.create(Unknown Source) > > > ==================================================================== > > > > > > gbEntry.java > > > ================================================================== > > > package com.morelogs.guestbook.xdoclets; > > > > > > import javax.ejb.*; > > > import com.morelogs.guestbook.interfaces.*; > > > > > > /** > > > * This is an gbEntry bean. It is an example of how to use the > > > * EJBDoclet tags. > > > * > > > * @see Customer gbEntries are owned by gbUsers, and a gbUser can > > > * have many gbEntries. > > > * > > > * @ejb:bean name="guestbook/gbEntry" > > > * type="CMP" > > > * jndi-name="ejb/guestbook/gbEntry" > > > * primkey-field="entry_id" > > > * @ejb:finder signature="Collection findAll()" > > > * unchecked="true" > > > * @ejb:interface > > remote-class="com.morelogs.guestbook.interfaces.gbEntry" > > > * > > > * @jboss:table-name gbEntries > > > * @jboss:data-source-name ejbGuestbookDS > > > * @jboss:persistence > > > */ > > > public abstract class gbEntry implements javax.ejb.EntityBean { > > > > > > private javax.ejb.EntityContext _entityContext; > > > > > > /** > > > * @param entry_id of this gbEntry > > > */ > > > public abstract void setEntry_id(java.lang.Integer entry_id); > > > > > > /** > > > * @return id of this gb entry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @ejb:pk-field > > > */ > > > public abstract java.lang.Integer getEntry_id(); > > > > > > > > > /** > > > * @param name author_id of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name author_id > > > */ > > > public abstract void setAuthor_id(java.lang.Integer author_id); > > > > > > /** > > > * @return author_id of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name author_id > > > */ > > > public abstract java.lang.Integer getAuthor_id(); > > > > > > > > > /** > > > * @param entry_subject of gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_subject > > > */ > > > public abstract void setEntry_subject(java.lang.String > > entry_subject); > > > > > > /** > > > * @return subject of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_subject > > > */ > > > public abstract java.lang.String getEntry_subject(); > > > > > > > > > /** > > > * @param text of gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_text > > > */ > > > public abstract void setEntry_text(java.lang.String entry_text); > > > > > > /** > > > * @return text of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_text > > > */ > > > public abstract java.lang.String getEntry_text(); > > > > > > > > > /** > > > * @param date of gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_date > > > */ > > > public abstract void setEntry_date(java.lang.String entry_date); > > > > > > /** > > > * @return date of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_date > > > */ > > > public abstract java.lang.String getEntry_date(); > > > > > > > > > /** > > > * @param views of gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_views > > > */ > > > public abstract void setEntry_views(java.lang.Integer entry_views); > > > > > > /** > > > * @return views of this gbEntry > > > * > > > * @ejb:interface-method both > > > * @ejb:persistent-field > > > * @jboss:column-name entry_views > > > */ > > > public abstract java.lang.Integer getEntry_views(); > > > > > > /** > > > * Create gbEntry. > > > * > > > * @ejb:create-method > > > * @ejb:permission role-name="Administrator" > > > */ > > > public gbEntryPK ejbCreate(Integer entry_id) throws CreateException > > { > > > setEntry_id(entry_id); > > > > > > return null; > > > } > > > > > > public void ejbPostCreate(Integer entry_id) throws CreateException > > { > > > } > > > > > > public void setEntityContext(javax.ejb.EntityContext entityContext) > > { > > > _entityContext = entityContext; > > > } > > > > > > public void unsetEntityContext() { > > > _entityContext = null; > > > } > > > > > > public void ejbLoad() { > > > } > > > > > > public void ejbActivate() { > > > } > > > > > > public void ejbPassivate() { > > > } > > > > > > public void ejbRemove() throws javax.ejb.RemoveException { > > > } > > > > > > public void ejbStore() { > > > } > > > } > > > ============================================================== > > > > > > ejb-jar.xml > > > ============================================================== > > > <!-- Entity Beans --> > > > <entity > > > > <description><![CDATA[This is an gbEntry > > bean.]]></description> > > > > > > <ejb-name>guestbook/gbEntry</ejb-name> > > > > > > <home>com.morelogs.guestbook.interfaces.gbEntryHome</home> > > > <remote>com.morelogs.guestbook.interfaces.gbEntry</remote> > > > > > > > > <ejb-class>com.morelogs.guestbook.beans.gbEntryCMP</ejb-class> > > > <persistence-type>Container</persistence-type> > > > > > > <prim-key-class>com.morelogs.guestbook.interfaces.gbEntryPK</prim-key- > > > class> > > > <reentrant>False</reentrant> > > > <cmp-version>2.x</cmp-version> > > > > > <abstract-schema-name>guestbook/gbEntry</abstract-schema-name> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>entry_id</field-name> > > > </cmp-field> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>author_id</field-name> > > > </cmp-field> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>entry_subject</field-name> > > > </cmp-field> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>entry_text</field-name> > > > </cmp-field> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>entry_date</field-name> > > > </cmp-field> > > > <cmp-field > > > > <description><![CDATA[]]></description> > > > <field-name>entry_views</field-name> > > > </cmp-field> > > > <primkey-field>entry_id</primkey-field> > > > > > > </entity> > > > =================================================================== > > > I would appreciate any help on this matter. > > > > > > Many thanks > > > > > > Michael > > > > > > > > > _______________________________________________________________ > > > > > > Have big pipes? SourceForge.net is looking for download mirrors. We > > supply > > > the hardware. You get the recognition. Email Us: > > [EMAIL PROTECTED] > > > _______________________________________________ > > > Xdoclet-user mailing list > > > [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > > > > > _______________________________________________________________ > > > > Have big pipes? SourceForge.net is looking for download mirrors. We > supply > > the hardware. You get the recognition. Email Us: > [EMAIL PROTECTED] > > _______________________________________________ > > Xdoclet-user mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] > _______________________________________________ > Xdoclet-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/xdoclet-user _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
