Hibernate version:
3.1.rc2 on JBoss 4.0.3SP1
Mapping documents:
Code:
<?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="teste.Teste" table="teste">
<id name="id" column="codigo">
<generator class="increment" />
</id>
<property name="campo" type="string">
<column name="campo" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Teste teste = new Teste();
teste.setCampo("campo");
session.save(teste);
Full stack trace of any exception that occurs:Code:
17:08:10,687 INFO [STDOUT] Hibernate: select max(codigo) from teste
17:08:10,734 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: teste.Teste, setter method of property: id
17:08:10,734 ERROR [BasicPropertyAccessor] expected type: java.lang.Long, actual value: java.lang.Long
17:08:10,734 INFO [STDOUT] org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of teste.Teste.id
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPro
pertyAccessor.java:104)
at org.hibernate.tuple.AbstractEntityTuplizer.setIdentifier(AbstractEnti
tyTuplizer.java:204)
at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(
AbstractEntityPersister.java:3261)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(Abstrac
tSaveEventListener.java:157)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:114)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGene
ratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrR
equestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTran
sient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:524)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:510)
at servlet.ServletTeste.doGet(ServletTeste.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: object is not an instance of decl
aring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPro
pertyAccessor.java:42)
... 34 more
Name and version of the database you are using:HSQLDB 1.8.0
The generated SQL (show_sql=true):select max(codigo) from teste
My class:
Code:
package teste;
public class Teste {
private Long id;
private String campo;
public String getCampo() {
return campo;
}
public void setCampo(String campo) {
this.campo = campo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
I have the same .jar (containing teste.Teste) file on .har and .war files, so that I can share the session factory among two web apps.
My deploy configuration:
- hibernate.har
->classes.jar
->META-INF
->jboss-service.xml
- webapp.war
->WEB-INF
->lib
->classes.jar
The expected type and the actual type are the same!
Thanks.