You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Fernando Bernardino <fe...@ptcom.com.br> on 2004/09/16 15:47:17 UTC
Really strange problem! Please Help!
Hi everybody!
I have a really strange problem. I'm working with OJB 1.0rc5, Oracle 8.1.7, JBoss 3.2.3.
I have a table with a atributte "dt_atualizacao" data type "date". If I update this table changing the value of "dt_atualizacao", only this, OJB is changing another atributte (the first that is not a pk) . Look the tests described:
<class-descriptor class="br.com.ptcom.webField.model.UsuarioVO" table="LAB.USUARIO" >
<field-descriptor
name="cdCgcCpf"
column="CD_CGC_CPF"
jdbc-type="INTEGER"
primarykey="true"
/>
<reference-descriptor
name="pessoaVO"
class-ref="br.com.ptcom.webField.model.PessoaVO"
auto-retrieve="true"
>
<foreignkey field-ref="cdCgcCpf"/>
<foreignkey field-ref="tpPessoa"/>
</reference-descriptor>
<field-descriptor
name="tpPessoa"
column="TP_PESSOA"
jdbc-type="VARCHAR"
primarykey="true"
/>
<field-descriptor
name="cdUsuario"
column="CD_USUARIO"
jdbc-type="VARCHAR"
primarykey="true"
/>
<field-descriptor
name="senha"
column="SENHA"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="dtAtualizacao"
column="DT_ATUALIZACAO"
jdbc-type="TIMESTAMP"
/>
<field-descriptor
name="nmUsuario"
column="NM_USUARIO"
jdbc-type="VARCHAR"
/>
<collection-descriptor
name="gruposUsuario"
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
element-class-ref="br.com.ptcom.webField.model.GrupoAplicacaoVO"
auto-retrieve="true"
auto-update="true"
auto-delete="false"
auto-insert="true"
indirection-table="LAB.USUARIO_GRUPO_APLICACAO"
>
<fk-pointing-to-this-class column="CD_CGC_CPF"/>
<fk-pointing-to-this-class column="TP_PESSOA"/>
<fk-pointing-to-this-class column="CD_USUARIO"/>
<fk-pointing-to-element-class column="CD_GRUPO"/>
</collection-descriptor>
</class-descriptor>
------------------------------------------------------------------------------------------------------------------------------
public class UsuarioVO implements java.io.Serializable {
private Integer cdCgcCpf;
private String cdUsuario;
private Timestamp dtAtualizacao;
private String nmUsuario;
private String senha;
private String tpPessoa;
private PessoaVO pessoaVO;
private Collection gruposUsuario;
}
------------------------------------------------------------------------------------------------------------------------------
Before the test:
CD_CGC_CPF T CD_USUARIO SENHA DT_ATUAL NM_USUARIO
---------- - ---------------------- -------------------- --------------- ---------------------
1 f 01 password 16/09/04 adm
------------------------------------------------------------------------------------------------------------------------------
A JUnit test without change the "dt_atualizacao".
public void testAlterarUsuario() {
try{
SegurancaBusinessDelegate segurancaBD = new SegurancaBusinessDelegate();
PessoaVO pessoaVO = new PessoaVO();
pessoaVO.setCdCgcCpf(new Integer(1));
pessoaVO.setTpPessoa("f");
UsuarioVO usuarioVO = new UsuarioVO();
usuarioVO.setPessoaVO(pessoaVO);
usuarioVO.setTpPessoa(pessoaVO.getTpPessoa());
usuarioVO.setCdUsuario(new String("01"));
usuarioVO = segurancaBD.filtrarUsuario(usuarioVO); // filter table
segurancaBD.alterarUsuario(usuarioVO); // update table
}catch(Exception e){
e.printStackTrace();
}
}
------------------------------------------------------------------------------------------------------------------------------
After the test: OK!
CD_CGC_CPF T CD_USUARIO SENHA DT_ATUAL NM_USUARIO
---------- - ---------------------- -------------------- --------------- ---------------------
1 f 01 password 16/09/04 adm
------------------------------------------------------------------------------------------------------------------------------
public void testAlterarUsuario() {
try{
SegurancaBusinessDelegate segurancaBD = new SegurancaBusinessDelegate();
PessoaVO pessoaVO = new PessoaVO();
pessoaVO.setCdCgcCpf(new Integer(1));
pessoaVO.setTpPessoa("f");
UsuarioVO usuarioVO = new UsuarioVO();
usuarioVO.setPessoaVO(pessoaVO);
usuarioVO.setTpPessoa(pessoaVO.getTpPessoa());
usuarioVO.setCdUsuario(new String("01"));
usuarioVO = segurancaBD.filtrarUsuario(usuarioVO); // filter table
GregorianCalendar cal = new GregorianCalendar();
Timestamp dateTime = new Timestamp(cal.getTimeInMillis());
usuarioVO.setDtAtualizacao(dateTime); // UPDATING THIS ONLY!!!
segurancaBD.alterarUsuario(usuarioVO); // update table
}catch(Exception e){
e.printStackTrace();
}
}
------------------------------------------------------------------------------------------------------------------------------
After the test the atributte "SENHA" have changed, but I change only the "dt_atualizacao"!!!!!!
CD_CGC_CPF T CD_USUARIO SENHA DT_ATUAL NM_USUARIO
-------------------- - ---------------------- -------------------- --------------- ---------------------
1 f 01 oó sword 16/09/04 adm
------------------------------------------------------------------------------------------------------------------------------
I made a debug and the object is normal, only the "dt_atualizacao" have changed. But the generated SQL have the atributte "SENHA" with the new value. I really don't know why!
Please help me!
Thanks,
Fernando Bernardino