Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

What am I trying to do ? While loading my project I get a weird exception:

rezg.admin.server.objects.common.pojo.EmailLogDetails, setter method of property: id

I am to save the object (persist) to the DB, using postgres. Environment is Java 6 , Hibernate 3 in Jboss 4 Environment. The jar contains "EmailLogDetails" is in the Jboss lib folder.

expected type: java.lang.Integer, actual value: java.lang.Integer IllegalArgumentException in class: rezg.admin.server.objects.common.pojo.EmailLogDetails, setter method of property: id

org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of rezg.admin.server.objects.common.pojo.EmailLogDetails.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:3261) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:157) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114).....

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:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 74 more

EmailLogDetails:

public class EmailLogDetails  implements java.io.Serializable {

private static final long serialVersionUID = 1L;
private java.lang.Integer id;
private String reservationNo;
private String mailSubject;
private String fromAddress;

public String getFromAddress() {
    return fromAddress;
}
public void setFromAddress(String fromAddress) {
    this.fromAddress = fromAddress;
}
public java.lang.Integer getId() {
    return id;
}
public void setId(java.lang.Integer id) {
    this.id = id;
}
public String getMailSubject() {
    return mailSubject;
}
public void setMailSubject(String mailSubject) {
    this.mailSubject = mailSubject;
}
public String getMailType() {
    return mailType;
}
}

XML

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "../server/default/conf/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="false" schema="@@portalname@@_admin">
<class   name="rezg.admin.server.objects.common.pojo.EmailLogDetails" table="emaillogdetails">

      <id name="Id" column="id" type="java.lang.Integer">
        <generator class="sequence">
          <param name="sequence">@@portalname@@_admin.seq_emaillogdetails</param>
        </generator>
    </id>

    <property name="reservationNo"  type="java.lang.String" >
        <column name="reservationno" length="20" not-null="false" sql-type="varchar" />
    </property>

    <property name="mailSubject"  type="java.lang.String" >
        <column name="mailsubject" length="500" not-null="false" sql-type="varchar" />
    </property>
share|improve this question
3  
what you are trying to do ???? –  ajduke Jun 11 '13 at 5:21
2  
Man you need to provide more details, or at least a piece of your source-code. –  null Jun 11 '13 at 5:38
    
I have added the code copied from the pojo and mapping xml –  kchaturanga Jun 11 '13 at 5:45

1 Answer 1

By the looks of it you are missing the default constructor. Hibernate looks for the default constructor to create instances before playing around with import and export of mapping information between DB and class.

share|improve this answer
    
I have another set of classes with same, Without constructor.. What i want tu know is why this "java.lang.Integer, actual value: java.lang.Integer" came as exception . because both types are same . –  kchaturanga Jun 11 '13 at 7:40
    
Add the default constructor and try please. –  Siddharth Jun 11 '13 at 7:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.