Error checking if entity exists
kafka Sep 22, 2002 11:18 AMHello,
I have CMP bean. When I used Integer class for primary key, my bean was working. When I create primary key class:
package count;
import java.io.Serializable;
public class CountPK implements Serializable {
public CountPK()
{
System.out.println(this.id + "konst1");
}
/* public CountPK(Integer param)
{
this.id = param;
System.out.println(this.id+ "konst2");
}
*/
public Integer getId()
{
return id;
}
public boolean equals(Object o)
{
System.out.println(this.id + "equals");
if (o instanceof CountPK)
{
CountPK otherKey = (CountPK)o;
return (id == otherKey.id);
} else return false;
}
public int hashCode()
{
System.out.println(this.id + "hash");
return id.hashCode();
}
public Integer id;
}
Now my bean deploy succesful, but when I try use from client I get this error:
2002-09-22 16:20:55,910 INFO [STDOUT] ejbCreate9kitas: 9
2002-09-22 16:20:55,910 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.CountBean] Create: pk=null
2002-09-22 16:20:55,910 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.CountBean] Executing SQL: SELECT COUNT(*) FROM count WHERE
2002-09-22 16:20:55,920 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.CountBean] Error checking if entity exists
java.sql.SQLException: ERROR: parser: parse error at or near ""
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
at org.postgresql.Connection.ExecSQL(Connection.java:398)
at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeQuery(LocalPreparedStatement.java:289)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityExists(JDBCCreateEntityCommand.java:154)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:127)
ejbCreate metod is:
public java.lang.Object ejbCreate(Integer id, Integer quantity)
throws CreateException, EJBException, SQLException {
setId(id);
setQuantity(quantity);
System.out.println("ejbCreate" + id + "kitas: " + quantity);
return null;
}
and 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>
<display-name>Count Entity Bean</display-name>
<enterprise-beans>
Count Entity Bean
<ejb-name>CountBean</ejb-name>
count.CountHome
count.Count
<ejb-class>count.CountBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Object</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>quantity</field-name></cmp-field>
<abstract-schema-name>CountBean</abstract-schema-name>
<!--<primkey-field>id</primkey-field>-->
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>CountBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
where error can be ?
thanks