-->
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.  [ 8 posts ] 
Author Message
 Post subject: hibernate property exception
PostPosted: Fri Feb 03, 2006 5:18 am 
Newbie

Joined: Thu Feb 02, 2006 1:30 am
Posts: 5
hi everybody,,,

when i m saving data in database,,,
i m getting this exception,,

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of temp.Temporary.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:460)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:509)



i have checked my property file, class, everything looks fine,,
why this exception occur and how can i solve it???

thanx in advance,,,,
:)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 5:30 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Looks like there is a descrepency in the type definition for temp.Temporary.id. Post your code and mappings but I suspect you have declared the wrong type somewwhere or it's a null when it shouldn't be...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 5:52 am 
Newbie

Joined: Thu Feb 02, 2006 1:30 am
Posts: 5
i have declared id type String .
in database it is varchar(128).
and in mapping file it is

<id
name="id"
column="id"
type="java.lang.String"
>
</id>



thanx for giving ur valuable time.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 6:36 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Can you post the code of your class ?

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 6:59 am 
Newbie

Joined: Thu Feb 02, 2006 1:30 am
Posts: 5
here is my class code..........

public class Temporary {
private String id = null;

private String tempId = null;

private int count = 0;

public Temporary() {
}

public void incrementCount() {
count++;
}

public void incrementCount(int iCount) {
count = count + iCount;
}

public void decrementCount() {
count--;
}

public int getCount() {
return count;
}

public void setCount(int count) {
this.count = count;
}

public void update() {

}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTempId() {
return tempId;
}

public void setTempId(String tempId) {
if (tempId != null) {
if (tempId.equals("")) {
tempId = null;
}
}
this.tempId = tempId;

}

}


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="temp.Temporary"
table="Temporary"
lazy="false"
>

<id
name="id"
column="id"
type="java.lang.String"
>
<generator class="uuid.hex">

</generator>
</id>

<property
name="count"
type="int"
update="true"
insert="true"
column="count"
/>


<property
name="tempId"
type="java.lang.String"
update="true"
insert="true"
column="tempId"
/>


</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 7:16 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Code:
public void setTempId(String tempId) {
  if (tempId != null) {
    if (tempId.equals("")) {
      tempId = null;
    }
  }
  this.tempId = tempId;


This is not a setter in the true sense - if I pass in "" it doesn not get set to "" and thus it has more logic...

It's just a hunch and I have no proper explaination, but if you change this to be a proper setter, does it work?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 7:41 am 
Newbie

Joined: Thu Feb 02, 2006 1:30 am
Posts: 5
thanx
but it doesn't work.

tempId is just a field that can be null.
id is primary key.

can u tell me when this

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of

exception occurs.

i m using hibernate's saveOrUpdate() method to save data.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 9:18 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
You can set a breakpoint in:
Code:
org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)

and see what happens.

_________________
dont forget to rate !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.