Hey,
few considerations / suggestions:
1) StringBuffer does not override hashCode, use String.hashCode; look here
for an example on how to implement correctly a PK's hashCode and equals:
http://www.ejbnow.com/ejbtips/ejbtip_1.html.
2) a instanceof A returns false if a == null; casts have a runtime overhead,
so the less you cast the better.
3) JBoss is smart enough to behave correctly even if PKs are not implemented
correctly, so your problem is elsewhere.
4) Unfortunately, you did not posted OS, JDK, JBoss' version, CMP or BMP,
server and client stack traces, nor the client code that receive the
exception... Post more info, and I'll try to help you if I can.
Regards,
Simon
> -----Original Message-----
> From: Paul Russo [mailto:[EMAIL PROTECTED]]
> Sent: sabato 6 gennaio 2001 21:46
> To: [EMAIL PROTECTED]
> Subject: [jBoss-User] CMP findByPrimaryKey multiple fields
>
>
> I have a primary key with multiple fields.
> When I try to do a findByPrimary key from a client, I get Object not
> found in storage. I know the database row exists. Also, I can make
> other findByPrimaryKey for CMP work by using a single field with no
> primary key class.
>
> I've included the primaryKey class and ejb-jar.xml and jaws xml files.
>
> I thank anybody who would take the time to look at this.
>
> package net.qspasp.ejbs.gl.tebnoml;
>
> public class TebNomlPk implements java.io.Serializable {
> public String cmpy;
> public String noml;
> public int path;
>
> private int hashCode;
>
> public TebNomlPk() {
> }
>
> public TebNomlPk(String cmpy, String noml, int path) {
> this.cmpy = cmpy;
> this.noml = noml;
> this.path = path;
>
> StringBuffer buff = new StringBuffer();
> buff.append(cmpy);
> buff.append(noml);
> buff.append(path);
> hashCode = buff.hashCode();
> }
>
> public boolean equals(Object key) {
> System.out.println("equals method");
> if ( (key == null)
> || !(key instanceof TebNomlPk) ) {
> System.out.println("equals =f1");
> return false;
> }
> if ( (((TebNomlPk)key).cmpy.equals(cmpy))
> && (((TebNomlPk)key).noml.equals(noml))
> && (((TebNomlPk)key).path == (path)) ) {
> System.out.println("equals =t1");
> return true;
> } else {
> System.out.println("equals =f2");
> return false;
> }
> }
>
> public int hashCode() {
> return hashCode;
> }
> }
>
>
> ejb-jar.xml
> --------------------
> <?xml version="1.0"?>
>
> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
> JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
>
> <ejb-jar>
> <enterprise-beans>
> <entity>
> <description>Deployment descriptor for TebNoml
> bean</description>
> <ejb-name>TebNomlHome</ejb-name>
> <home>net.qspasp.ejbs.gl.tebnoml.TebNomlHome</home>
> <remote>net.qspasp.ejbs.gl.tebnoml.TebNoml</remote>
> <ejb-class>net.qspasp.ejbs.gl.tebnoml.TebNomlBean</ejb-class>
> <persistence-type>Container</persistence-type>
>
> <prim-key-class>net.qspasp.ejbs.gl.tebnoml.TebNomlPk</prim-key-class>
> <reentrant>False</reentrant>
> <cmp-field><field-name>cmpy</field-name></cmp-field>
> <cmp-field><field-name>path</field-name></cmp-field>
> <cmp-field><field-name>noml</field-name></cmp-field>
> <cmp-field><field-name>descr_30</field-name></cmp-field>
> <resource-ref>
> <description>A jdbc connection for the CMP bean</description>
> <res-ref-name>QspDBPool</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </entity>
> </enterprise-beans>
> </ejb-jar>
>
>
> jaws.xml
> ---------
>
> <jaws>
> <datasource>xa.QspDBPool</datasource>
> <type-mapping>Oracle</type-mapping>
>
> <default-entity>
> <create-table>true</create-table>
> <remove-table>false</remove-table>
> <tuned-updates>true</tuned-updates>
> <read-only>false</read-only>
> <time-out>300</time-out>
> </default-entity>
>
> <type-mappings>
> <type-mapping>
> <name>Oracle</name>
> <mapping>
> <java-type>java.lang.Long</java-type>
> <jdbc-type>BIGINT</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.String</java-type>
> <jdbc-type>VARCHAR</jdbc-type>
> <sql-type>VARCHAR(256)</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.String</java-type>
> <jdbc-type>VARCHAR</jdbc-type>
> <sql-type>CHAR</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Character</java-type>
> <jdbc-type>CHAR</jdbc-type>
> <sql-type>CHAR</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Short</java-type>
> <jdbc-type>INTEGER</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.sql.TimeStamp</java-type>
> <jdbc-type>TIMESTAMP</jdbc-type>
> <sql-type>TIMESTAMP</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Double</java-type>
> <jdbc-type>DOUBLE</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Byte</java-type>
> <jdbc-type>TINYINT</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Boolean</java-type>
> <jdbc-type>BIT</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Float</java-type>
> <jdbc-type>FLOAT</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Object</java-type>
> <jdbc-type>JAVA_OBJECT</jdbc-type>
> <sql-type>JAVA_OBJECT</sql-type>
> </mapping>
> <mapping>
> <java-type>java.util.Date</java-type>
> <jdbc-type>DATE</jdbc-type>
> <sql-type>DATE</sql-type>
> </mapping>
> <mapping>
> <java-type>java.lang.Integer</java-type>
> <jdbc-type>INTEGER</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </mapping>
> </type-mapping>
> </type-mappings>
>
> <enterprise-beans>
> <entity>
> <ejb-name>TebNomlHome</ejb-name>
> <table-name>TEBNOML</table-name>
> <create-table>false</create-table>
> <cmp-field>
> <field-name>cmpy</field-name>
> <column-name>CMPY</column-name>
> <jdbc-type>VARCHAR</jdbc-type>
> <sql-type>VARCHAR(2)</sql-type>
> </cmp-field>
> <cmp-field>
> <field-name>noml</field-name>
> <column-name>NOML</column-name>
> <jdbc-type>VARCHAR</jdbc-type>
> <sql-type>VARCHAR(20)</sql-type>
> </cmp-field>
> <cmp-field>
> <field-name>path</field-name>
> <column-name>PATH</column-name>
> <jdbc-type>INTEGER</jdbc-type>
> <sql-type>NUMBER</sql-type>
> </cmp-field>
> <cmp-field>
> <field-name>descr_30</field-name>
> <column-name>DESCR_30</column-name>
> </cmp-field>
> </entity>
> </enterprise-beans>
> </jaws>
>
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]