-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: first application with hibernate & mysql getting excepti
PostPosted: Tue Jan 22, 2008 2:07 am 
Newbie

Joined: Tue Jan 22, 2008 2:02 am
Posts: 2
I am new to hibernate trying to create first application with hibernate and mysql ,
I am getting following exception


[java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Hibernate: insert into EVENTS (title) values (?)
[java] Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of src.events.Event.id
[java] at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
[java] at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3596)
[java] at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:54)
[java] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
[java] at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
[java] at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
[java] at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
[java] at $Proxy0.save(Unknown Source)
[java] at src.events.EventManager.createAndStoreEvent(EventManager.java:25)
[java] at src.events.EventManager.main(EventManager.java:10)
[java] Caused by: java.lang.IllegalArgumentException: argument type mismatch
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
[java] ... 23 more
[java] Java Result: 1


Top
 Profile  
 
 Post subject: Re: first application with hibernate & mysql getting exc
PostPosted: Tue Jan 22, 2008 11:21 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
What is the class code for Event and the corresponding hbm file? It looks like the type retrieved from DB and the type defined in the class for property id do not match.



Farzad-


Top
 Profile  
 
 Post subject: Re: first application with hibernate & mysql getting exc
PostPosted: Wed Jan 23, 2008 1:09 am 
Newbie

Joined: Tue Jan 22, 2008 2:02 am
Posts: 2
farzad wrote:
What is the class code for Event and the corresponding hbm file? It looks like the type retrieved from DB and the type defined in the class for property id do not match.



Farzad-


my hbm file looks like


<?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="src.events.Event" table="EVENTS" lazy="true">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="title" column="title" type="java.lang.String" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: first application with hibernate & mysql getting exc
PostPosted: Wed Jan 23, 2008 12:48 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
amit.c wrote:
my hbm file looks like


<?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="src.events.Event" table="EVENTS" lazy="true">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="title" column="title" type="java.lang.String" />
</class>
</hibernate-mapping>



What if instead of java.lang.Integer you use int? and instead of java.lang.String you use string?


Farzad-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.