[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Can not run sampel with ORACLE Strange Exception

stefan.lang@amigon.de do-not-reply at jboss.com
Thu Mar 15 12:46:43 EDT 2007


I get the following exeption on server side

17:31:21,064 INFO  [STDOUT] Hibernate: select car_sequence.nextval from dual
17:31:21,070 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: com.jbossatwork.common.CarDTO, setter method of property: id
17:31:21,070 ERROR [BasicPropertyAccessor] expected type: int, actual value: java.lang.Integer


ORACLE is:

CREATE TABLE CAR
(
  ID          NUMBER,
  MAKE        VARCHAR2(50 BYTE),
  MODEL       VARCHAR2(50 BYTE),
  MODEL_YEAR  VARCHAR2(50 BYTE)
)

CAR_SEQUENCE 

Code is (from JBossAtWork Book)


public class CarDTO
{
    private int id;
    private String make;
    private String model;
    private String modelYear;

    public CarDTO()
    {
        this.id = -1;
        this.make = "";
        this.model = "";
        this.modelYear = "";        
    }

    public CarDTO(String make, String model, String modelYear)
    {
        this.id = -1;
        this.make = make;
        this.model = model;
        this.modelYear = modelYear;
    }

    public CarDTO( int id, String make, String model, String modelYear)
    {
        this.id = id;
        this.make = make;
        this.model = model;
        this.modelYear = modelYear;
    }


    /**
     * @hibernate.id
     *    generator-class="sequence"
     *    column="ID"
     */
    public int getId()
    {
        return id;
    }
    
    public void setId(int id)
    {
        this.id = id;
    }

    /**
     * @hibernate.property
     *    column="MAKE"
     */
    public String getMake()
    {
        return make;
    }

    public void setMake(String make)
    {
        this.make = make;
    }

    /**
     * @hibernate.property
     *    column="MODEL"
     */
    public String getModel()
    {
        return model;
    }

    public void setModel(String model)
    {
        this.model = model;
    }

    /**
     * @hibernate.property
     *    column="MODEL_YEAR"
     */
    public String getModelYear()
    {
        return modelYear;
    }

    public void setModelYear(String modelYear)
    {
        this.modelYear = modelYear;
    }
}




hibernate mapping is:


<hibernate-mapping>
    

        
            
              <!--  
                  To add non XDoclet generator parameters, create a file named 
                  hibernate-generator-params-CarDTO.xml 
                  containing the additional parameters and place it in your merge dir. 
              --> 
            car_sequence              
            
        

        

        

        

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-CarDTO.xml
            containing the additional properties and place it in your merge dir.
        -->

    
</hibernate-mapping>



Code snipet to call hibernate on JBoss is:


            session = ServiceLocator.getHibernateSession (HIBERNATE_SESSION_FACTORY); 
            tx = session.beginTransaction();
            session.save(car);
            tx.commit();
 


The total original code of the book is in addition not working. Here the tyep of ID was in the HBM just "int". Hibernate handbook had as type onyl "integer".

Jboss is 4.0.5 on HP-UX PA-RISK




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4028457#4028457

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4028457



More information about the jboss-user mailing list