-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.PropertyAccessException: IllegalArgumentExcept
PostPosted: Mon Sep 04, 2006 12:55 pm 
Newbie

Joined: Thu Nov 18, 2004 9:54 am
Posts: 3
Location: Maringa - Parana - Brazil
Alright!!! I really need some help here :-)

I getting the following Exception when I trying to test my code:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of br.com.agropommet.bd.cadastro.modelo.Cadastro.id
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
at org.hibernate.tuple.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:204)
at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3262)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:120)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:161)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:770)
at br.com.agropommet.bd.cadastro.negocio.CadastroBD.get(CadastroBD.java:52)
at br.com.agropommet.teste.ServletTesteInsercaoCadastro.doGet(ServletTesteInsercaoCadastro.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at br.com.agropommet.login.FilterPermissao.doFilter(FilterPermissao.java:82)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
... 28 more


##########################################

The POJO:

public final class Cadastro {

private int id;
private int idMestre;
private String tipo;
private String tipoPessoa;
private String nome;
private String apelido;
private String cpf;
private String rg;
private String dataRG; // data no formato pt-BR
private String localRG;
private String outroDocumento;
private String estadoCivil;
private String regimeCasamento;
private String dataNascimento; // data no formato pt-BR
private String naturalPais;
private String naturalCidade;
private String naturalEstado;
private String dataInsercao; // data no formato pt-BR
private String horaInsercao;
private String status;
private SimpleDateFormat dateFormatBR;
private SimpleDateFormat dateFormatUS;

public Cadastro() {
this.dateFormatBR = new SimpleDateFormat("dd/MM/yyyy");
this.dateFormatUS = new SimpleDateFormat("yyyy-MM-dd");
}

private String converterParaUS(String dataBR) throws ParseException {
Date date = this.dateFormatBR.parse(dataBR);
String data = this.dateFormatUS.format(date);
return data;
}

private String converterParaBR(String dataUS) throws ParseException {
Date date = this.dateFormatUS.parse(dataUS);
String data = this.dateFormatBR.format(date);
return data;
}

public String getApelido() {
return apelido;
}

public String getCpf() {
return cpf;
}

public String getDataInsercao() {
return dataInsercao;
}

public String getDataInsercaoUS() throws ParseException {
return this.converterParaUS(this.getDataInsercao());
}

public String getDataNascimento() {
return dataNascimento;
}

public String getDataNascimentoUS() throws ParseException {
return this.converterParaUS(this.getDataNascimento());
}

public String getDataRG() {
return dataRG;
}

public String getDataRGUS() throws ParseException {
return this.converterParaUS(this.getDataRG());
}

public String getEstadoCivil() {
return estadoCivil;
}

public String getHoraInsercao() {
return horaInsercao;
}

public int getId() {
return id;
}

public int getIdMestre() {
return idMestre;
}

public String getLocalRG() {
return localRG;
}

public String getNaturalCidade() {
return naturalCidade;
}

public String getNaturalEstado() {
return naturalEstado;
}

public String getNaturalPais() {
return naturalPais;
}

public String getNome() {
return nome;
}

public String getOutroDocumento() {
return outroDocumento;
}

public String getRegimeCasamento() {
return regimeCasamento;
}

public String getRg() {
return rg;
}

public String getStatus() {
return status;
}

public String getTipo() {

return tipo;
}

public String getTipoPessoa() {
return tipoPessoa;
}

public void setTipoPessoa(String tipoPessoa) {
this.tipoPessoa = tipoPessoa;
}

public void setTipo(String tipo) {

this.tipo = tipo;
}

public void setStatus(String status) {
this.status = status;
}

public void setRg(String rg) {
this.rg = rg;
}

public void setRegimeCasamento(String regimeCasamento) {
this.regimeCasamento = regimeCasamento;
}

public void setOutroDocumento(String outroDocumento) {
this.outroDocumento = outroDocumento;
}

public void setNome(String nome) {
this.nome = nome;
}

public void setNaturalPais(String naturalPais) {
this.naturalPais = naturalPais;
}

public void setNaturalEstado(String naturalEstado) {
this.naturalEstado = naturalEstado;
}

public void setNaturalCidade(String naturalCidade) {
this.naturalCidade = naturalCidade;
}

public void setLocalRG(String localRG) {
this.localRG = localRG;
}

public void setIdMestre(int idMestre) {
this.idMestre = idMestre;
}

public void setId(int id) {
this.id = id;
}

public void setHoraInsercao(String horaInsercao) {
this.horaInsercao = horaInsercao;
}

public void setEstadoCivil(String estadoCivil) {
this.estadoCivil = estadoCivil;
}

public void setDataRG(String dataRG) {
this.dataRG = dataRG;
}

public void setDataNascimento(String dataNascimento) {
this.dataNascimento = dataNascimento;
}

public void setDataInsercao(String dataInsercao) {
this.dataInsercao = dataInsercao;
}

public void setCpf(String cpf) {
this.cpf = cpf;
}

public void setApelido(String apelido) {
this.apelido = apelido;
}

}

##########################################

The hbm:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="br.com.agropommet.bd.cadastro.modelo.Cadastro" table="tb_agp_cadastro">
<id name="id" column="id" type="int" >
<generator class="increment"/>
</id>

<property name="idMestre" type="int" column="id_mestre" not-null="true" />
<property name="tipo" type="java.lang.String" column="tipo" not-null="true" />
<property name="tipoPessoa" type="java.lang.String" column="tipo_pessoa" not-null="true" />
<property name="nome" type="java.lang.String" column="nome" not-null="true" />
<property name="apelido" type="java.lang.String" column="apelido" not-null="false" />
<property name="cpf" type="java.lang.String" column="cpf" not-null="true" />
<property name="rg" type="java.lang.String" column="rg" not-null="true" />
<property name="dataRG" type="java.lang.String" column="data_rg" not-null="false" />
<property name="localRG" type="java.lang.String" column="local_rg" not-null="false" />
<property name="outroDocumento" type="java.lang.String" column="outro_documento" not-null="false" />
<property name="estadoCivil" type="java.lang.String" column="estado_civil" not-null="false" />
<property name="regimeCasamento" type="java.lang.String" column="regime_casamento" not-null="false" />
<property name="dataNascimento" type="java.lang.String" column="data_nascimento" not-null="false" />
<property name="naturalPais" type="java.lang.String" column="natural_pais" not-null="false" />
<property name="naturalEstado" type="java.lang.String" column="natural_estado" not-null="false" />
<property name="naturalCidade" type="java.lang.String" column="natural_cidade" not-null="false" />
<property name="dataInsercao" type="java.lang.String" column="data_insercao" not-null="false" />
<property name="status" type="java.lang.String" column="status" not-null="true" />

</class>
</hibernate-mapping>

##########################################

The test code:

public Cadastro get(Cadastro cadastro) throws NamingException, SQLException {

Session session = this.agropommetUtil.getSessionFactory().openSession();
session.load(cadastro, LockMode.None);
session.close();

return cadastro;
}

##########################################

The database: (Note it´s MySQL 5.xx)

CREATE TABLE `agropommet`.`tb_agp_cadastro` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_mestre` int(10) unsigned NOT NULL,
`tipo` varchar(15) NOT NULL,
`tipo_pessoa` set('FISICA','JURIDICA') NOT NULL default 'FISICA',
`nome` varchar(70) NOT NULL,
`apelido` varchar(20) default NULL,
`cpf` varchar(18) NOT NULL,
`rg` varchar(20) NOT NULL,
`data_rg` varchar(45) default NULL,
`local_rg` varchar(45) default NULL,
`outro_documento` varchar(20) default NULL,
`estado_civil` varchar(45) default NULL,
`regime_casamento` varchar(45) default NULL,
`data_nascimento` date default NULL,
`natural_pais` varchar(45) default NULL,
`natural_estado` varchar(45) default NULL,
`natural_cidade` varchar(45) default NULL,
`data_insercao` datetime default NULL,
`status` set('A','B') NOT NULL default 'A',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


##########################################


I really don't know what's going on. It's mistery :-)

Help!!!

thanx in advance.

---
Rodrigo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.