[jboss-user] [JBoss Portal] - Re: Data access / persistence - could you help?

JohnnyTheHun do-not-reply at jboss.com
Mon Nov 26 15:16:55 EST 2007


Thank you for answering, 
I am moving step by step, but moving nontheless.

I tried creating and persisting EJB beans, but there where too many unknown errors, so know I'm trying to just persist a simple class with Hibernate.

But I am still unable to persist a class, because of the following exception:

  | org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of a.b.c.Cikk.cim
  | org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
  | org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of a.b.c.Cikk.cim
  | org.hibernate.property.BasicPropertyAccessor$BasicGetter.getForInsert(BasicPropertyAccessor.java:182)
  | org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of a.b.c.Cikk.cim
  | org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:271)
  | org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of a.b.c.Cikk.cim
  | ....
  | 

If anyone could lend a hand, I would be happy.

I created my Hibernate mbean in my .har in the jboss-service.xml file:


  | </mbean>
  | <mbean code="org.jboss.hibernate.jmx.Hibernate" 
  |            name="jboss.har:service=Hibernate">
  |         <attribute name="DatasourceName">java:/DefaultDS</attribute>
  |         <attribute name="Dialect">
  |             org.hibernate.dialect.HSQLDialect
  |         </attribute>
  |         <attribute name="SessionFactoryName">
  |             java:/hibernate/SessionFactory
  |         </attribute>
  | 
  |         <attribute name="ScanForMappingsEnabled">true</attribute>
  |         <attribute name="Hbm2ddlAuto">create</attribute> 
  |     </mbean>
  | 
  | 

My simple class I want to be able to persist:

  | package a.b.c;
  | 
  | import java.io.Serializable;
  | import javax.persistence.Id;
  | import javax.persistence.*;
  | 
  | /*@Entity
  | @Table(name = "cikk")*/
  | public class Cikk implements Serializable{
  |     private Long id;
  |     private String cim="Alapérték";
  |     private String valami="Alapérték";
  |     
  |     /** Creates a new instance of Cikk */
  |     public Cikk() {
  |     }
  |     
  |     public Cikk(Long id,String cim) {
  |         setId(id);
  |         setCim(cim);
  |     }
  |     
  |     public Cikk(String cim) {        
  |         setCim(cim);
  |     }
  |     
  |     //@Id
  |     public Long getId() { return id; }
  |     
  |     public void setId(Long id) {
  |         this.id = id;
  |     }
  |     
  |     public String getCim() {
  |         return cim;
  |     }
  |     
  |     public void setCim(String cim) {
  |         this.cim = cim;
  |     }
  | 
  |     public String getValami() {
  |         return valami;
  |     }
  | 
  |     public void setValami(String valami) {
  |         this.valami = valami;
  |     }
  |     
  | }
  | 

I wanted to use annotations for persistance, but Hibernate was unable to find them, I didn't find how to use the Annotation SessionFactory or something like that. (I tried a persistance.xml with mapping class, but that didn't help)

So I created my mapping file cikk.hbm.xml instead:

  | <?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="a.b.c.Cikk" table="cikk">
  |     <id name="id">
  |         <generator class="native"/>
  |     </id>    
  |     <property name="cim"/>
  |     <property name="valami"/>
  |   </class>
  | </hibernate-mapping>
  | 


I do not know why I get the exception.
I tried taking properties out from the mapping file, until only the id remained, but the error persisted, except it said:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling setter of a.b.c.Cikk.id


I must be missing something basic, can anyone help?

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

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




More information about the jboss-user mailing list