Date problem in Oracle 8 (CMP & Composite PK)
lbroudoux Nov 14, 2001 10:12 AMHi,
I'm using jboss2.4.1, oracle 8 for CMP entities.
I'm having some problems with a date field of a composite Primary Key class for a CMP entity bean.
Every finders on the home interface beans works fine,
but the load operation fails due to a casting problem (I think).
Here's the code of my composite PK :
import java.sql.Date;
import java.io.Serializable;
public class LignePK implements Serializable{
public Integer numligne;
public Date updatedate;
public LignePK(Integer num, Date dat){
numligne = num;
updatedate = dat;
}
public Integer getNumligne() {return numligne;}
public Date getUpdatedate() {return updatedate;}
public void setNumligne(Integer num) {numligne = num;}
public void setUpdatedate(Date dat) {updatedate = dat;}
public int hashCode() {return numligne.hashCode() * updatedate.hashCode();}
public boolean equals(Object obj){
LignePK otherpk = null;
try {otherpk = (LignePK)obj;}
catch (ClassCastException cce) {return false;}
return numligne.equals(otherpk.getNumligne()) && updatedate.equals(otherpk.getUpdatedate());
}
}
I've got the following exception trace (with jaws debug option on). One can see that the finder succeeds but the load command failed.
I've tried the same query in SQL+ and it fails because of the date format.
[JAWS] findByNumligne command executing: SELECT IT_PROP_LIGNE.N_LIGNE,IT_PROP_LIGNE.D_MAJ FROM IT_PROP_LIGNE where N_LIGNE = ? ORDER BY D_MAJ DESC
[JAWS] Set parameter: idx=1, jdbcType=INTEGER, value=17
[LigneBean] Activated bean LigneBean with id = mma.it.ligne.ejb.LignePK@67868e79
[JAWS] Load command executing: SELECT IT_PROP_LIGNE.N_LIGNE,IT_PROP_LIGNE.D_MAJ,IT_PROP_LIGNE.N_BDO_GDI,IT_PROP_LIGNE.C_URL,IT_PROP_LIGNE.C_UTILISATEURS,IT_PROP_LIGNE.N_BDO_BUREAU FROM IT_PROP_LIGNE WHERE N_LIGNE=? AND D_MAJ=?
[JAWS] Set parameter: idx=1, jdbcType=INTEGER, value=17
[JAWS] Set parameter: idx=2, jdbcType=DATE, value=2001-10-18
[LigneBean] TRANSACTION ROLLBACK EXCEPTION:Load failed; nested exception is:
java.rmi.NoSuchObjectException: Entity mma.it.ligne.ejb.LignePK@67868e79 not found; nested exception is:
java.rmi.ServerException: Load failed; nested exception is:
java.rmi.NoSuchObjectException: Entity mma.it.ligne.ejb.LignePK@67868e79 not found
[LigneBean] java.rmi.ServerException: Load failed; nested exception is:
[LigneBean] java.rmi.NoSuchObjectException: Entity mma.it.ligne.ejb.LignePK@67868e79 not found
[LigneBean] java.rmi.NoSuchObjectException: Entity mma.it.ligne.ejb.LignePK@67868e79 not found
[LigneBean] at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoadEntityCommand.java:172)
[LigneBean] at org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleResult(JDBCQueryCommand.java:59)
[LigneBean] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:160)
[LigneBean] at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:147)
[LigneBean] at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:156)
[LigneBean] ...
May the date format generated by jaws (as shown in trace above) be not compatible with Oracle ?
Has someone ever has the same problem and solved itby changing type-mapping ?
Is it possible to use String instead ? how ?
Thanks a lot.
Laurent