-->
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.  [ 1 post ] 
Author Message
 Post subject: PropertyAccessException: could not get a field value
PostPosted: Fri Mar 06, 2009 9:12 am 
Newbie

Joined: Thu Jan 29, 2009 10:18 am
Posts: 4
Hibernate version:
Core 3.3.1
Annotation 3.4.0

Full stack trace of any exception that occurs:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of xxx.Category.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:206)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3619)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3335)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204)
at org.hibernate.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:160)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:92)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:70)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:311)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)

Exception while saving object Characteristic.
Exception method: field.get(target);
field - java.lang.reflect.Field( Identity.id )
target - Integer (not null)

My classes and mapping.

Code:
@Entity
@SequenceGenerator(name="genId", sequenceName="characteristics_seq", allocationSize=1)
public class Characteristic extends Identity {
   
   @ManyToOne(targetEntity=Category.class, optional=false)
   private Integer category;
   ...
}

@Entity
@SequenceGenerator(name="genId", sequenceName="categories_seq", allocationSize=1)
public class Category extends Identity {
   ...
}

@MappedSuperclass
public abstract class Identity implements Identifiable {

   @Id
   @GeneratedValue(generator="genId")
   private Integer id;
   ...
}



I tried to debug. Maybe the problem is here, but i'm not sure
Code:
public Serializable getIdentifier(Object entity) throws HibernateException {
      final Object id;
      if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
         id = entity; //<-- here what i need
      }
      else {
         if ( idGetter == null ) {
            ...
         }
         else {
            id = idGetter.get( entity ); //<-- what hibernate tries to do
         }
      }
      ...


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

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.