Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Help me ... I tried everything what I could but I did not obtain to solve this problem.
Hibernate version:
Hibernate-Version: 3.2.0.ga
Mapping documents:
TipoEmail.java
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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.metrorio.sbe.pessoa.entity.TipoEmail"
table="t_tipo_email_pes">
<id name="id" column="id_tipo_email_pes" type="long"
unsaved-value="-1">
<generator class="sequence">
<param name="sequence">seq_t_tip_email</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-TipoEmail.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<set name="emails" lazy="true" cascade="all-delete-orphan"
sort="unsorted">
<key column="id_tipoEmail_email_fk"></key>
<one-to-many
class="br.com.metrorio.sbe.pessoa.entity.EmailPessoa" />
</set>
<property name="descricao" type="string" update="true"
insert="true" column="des_tipo_email_pes" length="30"
not-null="true" />
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-TipoEmail.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
EmailPessoa.javaCode:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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.metrorio.sbe.pessoa.entity.EmailPessoa"
table="t_email_pes">
<id name="id" column="id_email_pes" type="long"
unsaved-value="-1">
<generator class="sequence">
<param name="sequence">seq_t_email</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-EmailPessoa.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<many-to-one name="pessoa"
class="br.com.metrorio.sbe.pessoa.entity.Pessoa" cascade="none"
outer-join="auto" update="true" insert="true"
column="id_pessoa_email_fk" />
<property name="descricao" type="string" update="true"
insert="true" column="des_email_pes" length="60" not-null="true" />
<many-to-one name="tipoEmail"
class="br.com.metrorio.sbe.pessoa.entity.TipoEmail" cascade="none"
outer-join="auto" update="true" insert="true"
column="id_tipoEmail_email_fk" />
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-EmailPessoa.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Pessoa.java Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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.metrorio.sbe.pessoa.entity.Pessoa"
table="t_pessoa">
<id name="id" column="id_pessoa" type="long"
unsaved-value="-1">
<generator class="sequence">
<param name="sequence">seq_t_pessoa</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Pessoa.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<set name="emails" lazy="true" cascade="all-delete-orphan"
sort="unsorted">
<key column="id_pessoa_email_fk"></key>
<one-to-many
class="br.com.metrorio.sbe.pessoa.entity.EmailPessoa" />
</set>
<set name="enderecos" lazy="true" cascade="all-delete-orphan"
sort="unsorted">
<key column="id_pessoa_endereco_fk"></key>
<one-to-many
class="br.com.metrorio.sbe.pessoa.entity.EnderecoPessoa" />
</set>
<set name="fones" lazy="true" cascade="all-delete-orphan"
sort="unsorted">
<key column="id_pessoa_fone_fk"></key>
<one-to-many
class="br.com.metrorio.sbe.pessoa.entity.FonePessoa" />
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Pessoa.xml
containing the additional properties and place it in your merge dir.
-->
<joined-subclass
name="br.com.metrorio.sbe.pessoa.entity.PessoaFisica"
table="t_pessoa_fisica">
<key column="id_pessoa" />
<property name="dataNascimento" type="date" update="true"
insert="true" column="data_nasc_pf" not-null="true" />
<property name="estadoCivil" type="integer" update="true"
insert="true" column="estado_civil_pf" length="1" not-null="true" />
<property name="nome" type="string" update="true"
insert="true" column="nome_pf" length="50" not-null="true" />
<property name="numeroRg" type="integer" update="true"
insert="true" column="numero_rg_pf" length="12" not-null="true" />
<property name="sexo" type="integer" update="true"
insert="true" column="sexo_civil_pf" length="1" not-null="true" />
<property name="orgaoExpRg" type="string" update="true"
insert="true" column="org_exp_rg_pf" length="10" not-null="true" />
<property name="dataEmissaoRg" type="date" update="true"
insert="true" column="dat_emis_rg_pf" not-null="true" />
<joined-subclass
name="br.com.metrorio.sbe.usuario.entity.Usuario"
table="t_usuario">
<key column="id_pessoa" />
<property name="biometria" type="string" update="true"
insert="true" column="biometria_usuario" length="60"
not-null="false" />
<property name="foto" type="blob" update="true"
insert="true" column="foto_usuario" not-null="false" />
<joined-subclass
name="br.com.metrorio.sbe.funcionario.entity.FuncionarioMetroRio"
table="t_funcionario" lazy="true">
<key column="id_pessoa" />
<property name="codigoBarras" type="string"
update="true" insert="true" column="codigo_barras_func"
length="47" not-null="true" />
<property name="nucleoCompetencia" type="string"
update="true" insert="true" column="nucleo_comp_func" length="30"
not-null="true" />
<property name="numeroMatricula" type="integer"
update="true" insert="true" column="matricula_func"
not-null="true" />
<property name="tipoSanguineo" type="integer"
update="true" insert="true" column="tipo_sangu_func"
not-null="true" />
</joined-subclass>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():My session is managed by spring
Full stack trace of any exception that occurs:Code:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of br.com.metrorio.sbe.pessoa.entity.TipoEmail.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3524)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3240)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:137)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:282)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:437)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:326)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:625)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:622)
at br.com.metrorio.sbe.common.dao.BaseDaoImpl.salvar(BaseDaoImpl.java:69)
at br.com.metrorio.sbe.funcionario.service.ControlarFuncionarioServiceImpl.salvar(ControlarFuncionarioServiceImpl.java:60)
at br.com.metrorio.sbe.pessoa.facade.PessoaFacadeImpl.salvarFuncionarioMetroRio(PessoaFacadeImpl.java:264)
at br.com.metrorio.sbe.pessoa.apresentacao.web.action.EditarFuncionarioAction.executeAction(EditarFuncionarioAction.java:137)
at br.com.metrorio.sbe.common.action.GenericAction.execute(GenericAction.java:56)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
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 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: object is not an instance of declaring class
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$BasicGetter.get(BasicPropertyAccessor.java:145)
... 66 more
Name and version of the database you are using:PostgreSQL 8.1
The generated SQL (show_sql=true):The problem this occurring before executing the command sql.
Debug level Hibernate log excerpt:Code:
19:32:01,531[metro_rio] DEBUG SessionFactoryUtils:333 - Opening Hibernate Session
Hibernate: select nextval ('seq_t_pessoa')
Hibernate: select nextval ('seq_t_email')
Hibernate: select nextval ('seq_t_ender')
19:32:01,562[metro_rio] ERROR BasicPropertyAccessor:167 - IllegalArgumentException in class: br.com.metrorio.sbe.pessoa.entity.TipoEmail, getter method of property: id
19:32:01,562[metro_rio] DEBUG SessionFactoryUtils:779 - Closing Hibernate Session
19:32:01,562[metro_rio] WARN RequestProcessor:528 - Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateSystemException
19:32:01,562[metro_rio] ERROR [action]:253 - Servlet.service() for servlet action threw exception
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of br.com.metrorio.sbe.pessoa.entity.TipoEmail.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3524)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3240)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:137)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:282)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:437)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:326)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:625)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:622)
at br.com.metrorio.sbe.common.dao.BaseDaoImpl.salvar(BaseDaoImpl.java:69)
at br.com.metrorio.sbe.funcionario.service.ControlarFuncionarioServiceImpl.salvar(ControlarFuncionarioServiceImpl.java:60)
at br.com.metrorio.sbe.pessoa.facade.PessoaFacadeImpl.salvarFuncionarioMetroRio(PessoaFacadeImpl.java:264)
at br.com.metrorio.sbe.pessoa.apresentacao.web.action.EditarFuncionarioAction.executeAction(EditarFuncionarioAction.java:137)
at br.com.metrorio.sbe.common.action.GenericAction.execute(GenericAction.java:56)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
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 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: object is not an instance of declaring class
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$BasicGetter.get(BasicPropertyAccessor.java:145)
... 66 more