RE: Update Problem : Cannot convert class java.lang.Integer

2004-01-07 Thread Hennebelle
Hi !

Have you try to make a conversion in your repository ?
You have a class in OJB who convert INT on INTEGER (and the opposite), the
name is Int2IntegerFieldConversion.
You put a field in the repository like this (my example is a date, it works)
:
!--
 COLUMN D8CLEH


--

field-descriptor id=18
  name=d8cleh
  column=D8CLEH
  jdbc-type=TIMESTAMP

conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimest
ampFieldConversion

/
Here, my example convert a Date in an sql.Timestamp (in my bean class, the
attribute has the type : java.util.Date)


Hope this can help

Cheers

-Message d'origine-
De : António Jorge Silva [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 7 janvier 2004 05:14
À : [EMAIL PROTECTED]
Objet : Update Problem : Cannot convert class java.lang.Integer


Hi all !

I'm having  trouble when i try to update this object

the object is :

public class ComponenteAvaliacao implements IComponenteAvaliacao {
 private String _nome;
 private ISitio _sitio;
 private java.sql.Timestamp _inicioInscricoes;
 private java.sql.Timestamp _fimInscricoes;
 private int _peso;
 private int _classificacaoMinima;
 private java.sql.Timestamp _data;
 private int _duracao;
 private int _publicado;

 private List _notas;
 private List _inscritos;
 private List _salas;
 private List _pautas;

  // codigos internos da base de dados
 private int _codigoInterno;
 private int _chaveSitio;

}

With all the getters and setters and in OJB i have this

class-descriptor class=Dominio.ComponenteAvaliacao
table=COMPONENTEAVALIACAO
field-descriptor name=codigoInterno column=CODIGO_INTERNO
jdbc-type=INTEGER
  primarykey=true autoincrement=true/
field-descriptor name=nome column=NOME jdbc-type=VARCHAR/
field-descriptor name=chaveSitio column=CHAVE_SITIO
jdbc-type=INTEGER/
field-descriptor name=inicioInscricoes column=INICIO_INSCRICOES
jdbc-type=TIMESTAMP/
field-descriptor name=fimInscricoes column=FIM_INSCRICOES
jdbc-type=TIMESTAMP/
field-descriptor name=peso column=PESO jdbc-type=INTEGER/
field-descriptor name=classificacaoMinima
column=CLASSIFICACAO_MINIMA jdbc-type=INTEGER/
field-descriptor name=data column=DATA jdbc-type=TIMESTAMP/
field-descriptor name=duracao column=DURACAO
jdbc-type=INTEGER/
field-descriptor name=publicado column=PUBLICADO
jdbc-type=INTEGER/
reference-descriptor name=sitio class-ref=Dominio.Sitio 
foreignkey field-ref=chaveSitio/
/reference-descriptor
collection-descriptor name=notas
element-class-ref=Dominio.ResultadoAvaliacao
inverse-foreignkey field-ref=chaveAvaliacao/
/collection-descriptor
collection-descriptor name=inscritos
element-class-ref=Dominio.InscricaoComponenteAvaliacao
inverse-foreignkey field-ref=chaveAvaliacao/
/collection-descriptor
collection-descriptor

collection-class=org.apache.ojb.broker.util.collections.ManageableArrayList

name=salas
element-class-ref=Dominio.Sala
indirection-table=COMPONENTEAVALIACAOSALA
  
 fk-pointing-to-this-class column=CHAVE_AVALIACAO/
 fk-pointing-to-element-class column=CHAVE_SALA/
/collection-descriptor
collection-descriptor

collection-class=org.apache.ojb.broker.util.collections.ManageableArrayList

name=pautas
element-class-ref=Dominio.Pauta
indirection-table=PAUTACOMPONENTEAVALIACAO
  
 fk-pointing-to-this-class column=CHAVE_AVALIACAO/
 fk-pointing-to-element-class column=CHAVE_PAUTA/
/collection-descriptor
/class-descriptor

The dump of the exception was :

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the Update SQL query (for a
Dominio.ComponenteAvaliacao): Cannot convert class java.lang.Integer to SQL
type requested due to java.lang.ArrayIndexOutOfBoundsException - 2
Cannot convert class java.lang.Integer to SQL type requested due to
java.lang.ArrayIndexOutOfBoundsException - 2
java.sql.SQLException: Cannot convert class java.lang.Integer to SQL type
requested due to java.lang.ArrayIndexOutOfBoundsException - 2
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:861)
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:881)
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Un
known Source)
at
org.apache.ojb.broker.platforms.PlatformMySQLImpl.setObjectForStatement(Unkn
own Source)
at
org.apache.ojb.broker.accesslayer.StatementManager.bindValues(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeUpdateSQL(Unknown
Source)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeMtoNImplementor(Unknow
n Source)
at

RE: Update Problem : Cannot convert class java.lang.Integer

2004-01-07 Thread António Jorge Silva
Thank you for the answer but i've found the solution.

It's cause by a bad definition of a primary key in a table related with this
one.
That's quite a weird error message anyway.

Thank's for the help,
Antonio

-Original Message-
From: Hennebelle [mailto:[EMAIL PROTECTED]
Sent: quarta-feira, 7 de Janeiro de 2004 8:25
To: 'OJB Users List'
Subject: RE: Update Problem : Cannot convert class java.lang.Integer


Hi !

Have you try to make a conversion in your repository ?
You have a class in OJB who convert INT on INTEGER (and the opposite), the
name is Int2IntegerFieldConversion.
You put a field in the repository like this (my example is a date, it works)
:
!--
 COLUMN D8CLEH


--

field-descriptor id=18
  name=d8cleh
  column=D8CLEH
  jdbc-type=TIMESTAMP

conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimest
ampFieldConversion

/
Here, my example convert a Date in an sql.Timestamp (in my bean class, the
attribute has the type : java.util.Date)


Hope this can help

Cheers

-Message d'origine-
De : António Jorge Silva [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 7 janvier 2004 05:14
À : [EMAIL PROTECTED]
Objet : Update Problem : Cannot convert class java.lang.Integer


Hi all !

I'm having  trouble when i try to update this object

the object is :

public class ComponenteAvaliacao implements IComponenteAvaliacao {
 private String _nome;
 private ISitio _sitio;
 private java.sql.Timestamp _inicioInscricoes;
 private java.sql.Timestamp _fimInscricoes;
 private int _peso;
 private int _classificacaoMinima;
 private java.sql.Timestamp _data;
 private int _duracao;
 private int _publicado;

 private List _notas;
 private List _inscritos;
 private List _salas;
 private List _pautas;

  // codigos internos da base de dados
 private int _codigoInterno;
 private int _chaveSitio;

}

With all the getters and setters and in OJB i have this

class-descriptor class=Dominio.ComponenteAvaliacao
table=COMPONENTEAVALIACAO
field-descriptor name=codigoInterno column=CODIGO_INTERNO
jdbc-type=INTEGER
  primarykey=true autoincrement=true/
field-descriptor name=nome column=NOME jdbc-type=VARCHAR/
field-descriptor name=chaveSitio column=CHAVE_SITIO
jdbc-type=INTEGER/
field-descriptor name=inicioInscricoes column=INICIO_INSCRICOES
jdbc-type=TIMESTAMP/
field-descriptor name=fimInscricoes column=FIM_INSCRICOES
jdbc-type=TIMESTAMP/
field-descriptor name=peso column=PESO jdbc-type=INTEGER/
field-descriptor name=classificacaoMinima
column=CLASSIFICACAO_MINIMA jdbc-type=INTEGER/
field-descriptor name=data column=DATA jdbc-type=TIMESTAMP/
field-descriptor name=duracao column=DURACAO
jdbc-type=INTEGER/
field-descriptor name=publicado column=PUBLICADO
jdbc-type=INTEGER/
reference-descriptor name=sitio class-ref=Dominio.Sitio 
foreignkey field-ref=chaveSitio/
/reference-descriptor
collection-descriptor name=notas
element-class-ref=Dominio.ResultadoAvaliacao
inverse-foreignkey field-ref=chaveAvaliacao/
/collection-descriptor
collection-descriptor name=inscritos
element-class-ref=Dominio.InscricaoComponenteAvaliacao
inverse-foreignkey field-ref=chaveAvaliacao/
/collection-descriptor
collection-descriptor

collection-class=org.apache.ojb.broker.util.collections.ManageableArrayList

name=salas
element-class-ref=Dominio.Sala
indirection-table=COMPONENTEAVALIACAOSALA
  
 fk-pointing-to-this-class column=CHAVE_AVALIACAO/
 fk-pointing-to-element-class column=CHAVE_SALA/
/collection-descriptor
collection-descriptor

collection-class=org.apache.ojb.broker.util.collections.ManageableArrayList

name=pautas
element-class-ref=Dominio.Pauta
indirection-table=PAUTACOMPONENTEAVALIACAO
  
 fk-pointing-to-this-class column=CHAVE_AVALIACAO/
 fk-pointing-to-element-class column=CHAVE_PAUTA/
/collection-descriptor
/class-descriptor

The dump of the exception was :

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the Update SQL query (for a
Dominio.ComponenteAvaliacao): Cannot convert class java.lang.Integer to SQL
type requested due to java.lang.ArrayIndexOutOfBoundsException - 2
Cannot convert class java.lang.Integer to SQL type requested due to
java.lang.ArrayIndexOutOfBoundsException - 2
java.sql.SQLException: Cannot convert class java.lang.Integer to SQL type
requested due to java.lang.ArrayIndexOutOfBoundsException - 2
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:861)
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:881)
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Un