-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can not set Long field foo.id to java.util.LinkedHashSet
PostPosted: Thu Mar 04, 2010 5:09 am 
Newbie

Joined: Thu Mar 04, 2010 4:46 am
Posts: 3
Hello everyone

I'm having two classes/entities Device and Kpi. There is a @ManyToMany relation between those two, so a Device can have many Kpis and a Kpi can belong to many devices. I can successfully store and update both entities by themselves as long as I don't add Kpis to a device.
When debugging, I see that the set of the device instance is correctly filled with the Kpis, but the call to entityManager.update(device) then fails with the following error (the full stackstrace is at the end).

Code:
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field net.junisphere.eranger.domain.GenericEntity.id to java.util.LinkedHashSet
   at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
   at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
   at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
   at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
   at java.lang.reflect.Field.get(Field.java:358)
   at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
   ... 91 more


The entities look like:
Code:
@Entity
@RooJavaBean
@RooToString
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class GenericEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)   
    @Column(name = "id")
    private Long id;
}
// ----------------------------------------------------------------------
@Entity
@RooJavaBean
@RooToString
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class NamedEntity extends GenericEntity {
    @NotNull
    @Size(min = 2)
    private String name;
}
// ----------------------------------------------------------------------
@Entity
@RooJavaBean
@RooToString
public class Device extends NamedEntity {
    private String address;
   
    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Kpi> deviceKpis = new HashSet<Kpi>();
}
// ----------------------------------------------------------------------
@Entity
@RooJavaBean
@RooToString
public class Kpi extends NamedEntity  {
   private String unit;
}


The DevicesDAO that handles storing and retrieving Devices:
Code:
public interface IGenericRepository<T extends GenericEntity> {
   @Transactional
   void update(T o);
}
// ----------------------------------------------------------------------
public interface IDeviceRepository extends IGenericRepository<Device> { }
// ----------------------------------------------------------------------
abstract class GenericRepositoryJpaImpl<T extends GenericEntity> implements IGenericRepository<T> {
    @PersistenceContext
    private EntityManager entityManager;

    @Override
    @Transactional
    public void update(T o) {
   if (o == null) throw new IllegalArgumentException("An object is required");
   T merged = entityManager.merge(o);
   entityManager.flush();       
   o.setId(merged.getId());     
    }
    // .....
}
// ----------------------------------------------------------------------
@Repository
public class DeviceRepositoryJpaImpl extends GenericRepositoryJpaImpl<Device> {
}
// ----------------------------------------------------------------------
@Repository
public class DeviceRepository implements IDeviceRepository {
   // Why we don't use inheritance here, but collaboration:
   // http://codebetter.com/blogs/gregyoung/archive/2009/01/16/ddd-the-generic-repository.aspx
   
   @Autowired
   private DeviceRepositoryJpaImpl genericRepository;

   @Override
   public void update(Device device) {
      genericRepository.update(device);
   }
}



Do you have any Idea what could cause this error?


Thank you very much.
James





Code:
2010-03-04 09:39:29,328 [http-8080-1] TRACE org.hibernate.event.def.DefaultInitializeCollectionEventListener - initializing collection [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:29,328 [http-8080-1] TRACE org.hibernate.event.def.DefaultInitializeCollectionEventListener - checking second-level cache
2010-03-04 09:39:29,328 [http-8080-1] TRACE org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection not cached
2010-03-04 09:39:29,328 [http-8080-1] DEBUG org.hibernate.loader.Loader - loading collection: [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:29,328 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2010-03-04 09:39:29,328 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2010-03-04 09:39:29,328 [http-8080-1] DEBUG org.hibernate.SQL - select devicekpis0_.device as device1_, devicekpis0_.device_kpis as device2_1_, kpi1_.id as id3_0_, kpi1_1_.name as name4_0_, kpi1_.unit as unit7_0_ from device_device_kpis devicekpis0_ left outer join kpi kpi1_ on devicekpis0_.device_kpis=kpi1_.id left outer join named_entity kpi1_1_ on kpi1_.id=kpi1_1_.id left outer join generic_entity kpi1_2_ on kpi1_.id=kpi1_2_.id where devicekpis0_.device=?
Hibernate: select devicekpis0_.device as device1_, devicekpis0_.device_kpis as device2_1_, kpi1_.id as id3_0_, kpi1_1_.name as name4_0_, kpi1_.unit as unit7_0_ from device_device_kpis devicekpis0_ left outer join kpi kpi1_ on devicekpis0_.device_kpis=kpi1_.id left outer join named_entity kpi1_1_ on kpi1_.id=kpi1_1_.id left outer join generic_entity kpi1_2_ on kpi1_.id=kpi1_2_.id where devicekpis0_.device=?
2010-03-04 09:39:29,328 [http-8080-1] TRACE org.hibernate.jdbc.AbstractBatcher - preparing statement
2010-03-04 09:39:29,328 [http-8080-1] TRACE org.hibernate.type.LongType - binding '1' to parameter: 1
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - constructing collection load context for result set [org.apache.commons.dbcp.DelegatingResultSet@45f4ae]
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - starting attempt to find loading collection [[net.junisphere.eranger.domain.Device.deviceKpis#1]]
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - collection not yet initialized; initializing
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.loader.Loader - processing result set
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.loader.Loader - done processing result set (0 rows)
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.jdbc.AbstractBatcher - closing statement
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.loader.Loader - total objects hydrated: 0
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - attempting to locate loading collection entry [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] in any result-set context
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - collection [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] located in load context
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - removing collection load entry [org.hibernate.engine.loading.LoadingCollectionEntry<rs=org.apache.commons.dbcp.DelegatingResultSet@45f4ae, coll=[net.junisphere.eranger.domain.Device.deviceKpis#1]>@103368e]
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections were found in result set for role: net.junisphere.eranger.domain.Device.deviceKpis
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - ending loading collection [org.hibernate.engine.loading.LoadingCollectionEntry<rs=org.apache.commons.dbcp.DelegatingResultSet@45f4ae, coll=[net.junisphere.eranger.domain.Device.deviceKpis#1]>@103368e]
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - collection fully initialized: [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections initialized for role: net.junisphere.eranger.domain.Device.deviceKpis
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy collections
2010-03-04 09:39:29,343 [http-8080-1] DEBUG org.hibernate.loader.Loader - done loading collection
2010-03-04 09:39:29,343 [http-8080-1] TRACE org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection initialized
2010-03-04 09:39:29,406 [http-8080-1] TRACE org.hibernate.impl.SessionImpl - closing session
2010-03-04 09:39:29,406 [http-8080-1] TRACE org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action
2010-03-04 09:39:31,562 [http-8080-1] TRACE org.hibernate.validator.metadata.BeanMetaDataImpl - Members of the default group sequence for bean net.junisphere.eranger.domain.Device are: [interface javax.validation.groups.Default]
2010-03-04 09:39:31,640 [http-8080-1] TRACE org.hibernate.validator.metadata.BeanMetaDataImpl - Members of the default group sequence for bean net.junisphere.eranger.domain.NamedEntity are: [interface javax.validation.groups.Default]
2010-03-04 09:39:31,656 [http-8080-1] TRACE org.hibernate.validator.engine.ConstraintTree - Validating value asdfasdf against constraint defined by ConstraintDescriptorImpl{annotation=javax.validation.constraints.NotNull, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_IN_HIERARCHY, groups=[interface javax.validation.groups.Default], attributes={message={javax.validation.constraints.NotNull.message}, payload=[Ljava.lang.Class;@1123787, groups=[Ljava.lang.Class;@fbb5f5}}
2010-03-04 09:39:31,656 [http-8080-1] TRACE org.hibernate.validator.engine.ConstraintTree - Validating value asdfasdf against constraint defined by ConstraintDescriptorImpl{annotation=javax.validation.constraints.Size, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_IN_HIERARCHY, groups=[interface javax.validation.groups.Default], attributes={message={javax.validation.constraints.Size.message}, min=2, payload=[Ljava.lang.Class;@7b2e05, max=2147483647, groups=[Ljava.lang.Class;@10a621a}}
2010-03-04 09:39:31,656 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12676919716
2010-03-04 09:39:31,656 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - begin
2010-03-04 09:39:31,656 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2010-03-04 09:39:31,656 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: true
2010-03-04 09:39:31,656 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - disabling autocommit
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.jdbc.JDBCContext - after transaction begin
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.IdentifierValue - id unsaved-value: null
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.event.def.AbstractSaveEventListener - detached instance of: net.junisphere.eranger.domain.Device
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.event.def.DefaultMergeEventListener - merging detached instance
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.event.def.DefaultLoadEventListener - loading entity: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.persister.entity.AbstractEntityPersister - Fetching entity: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.loader.Loader - loading entity: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.SQL - select device0_.id as id3_1_, device0_1_.name as name4_1_, device0_.address as address5_1_, devicekpis1_.device as device3_, kpi2_.id as device2_3_, kpi2_.id as id3_0_, kpi2_1_.name as name4_0_, kpi2_.unit as unit7_0_ from device device0_ inner join named_entity device0_1_ on device0_.id=device0_1_.id inner join generic_entity device0_2_ on device0_.id=device0_2_.id left outer join device_device_kpis devicekpis1_ on device0_.id=devicekpis1_.device left outer join kpi kpi2_ on devicekpis1_.device_kpis=kpi2_.id left outer join named_entity kpi2_1_ on kpi2_.id=kpi2_1_.id left outer join generic_entity kpi2_2_ on kpi2_.id=kpi2_2_.id where device0_.id=?
Hibernate: select device0_.id as id3_1_, device0_1_.name as name4_1_, device0_.address as address5_1_, devicekpis1_.device as device3_, kpi2_.id as device2_3_, kpi2_.id as id3_0_, kpi2_1_.name as name4_0_, kpi2_.unit as unit7_0_ from device device0_ inner join named_entity device0_1_ on device0_.id=device0_1_.id inner join generic_entity device0_2_ on device0_.id=device0_2_.id left outer join device_device_kpis devicekpis1_ on device0_.id=devicekpis1_.device left outer join kpi kpi2_ on devicekpis1_.device_kpis=kpi2_.id left outer join named_entity kpi2_1_ on kpi2_.id=kpi2_1_.id left outer join generic_entity kpi2_2_ on kpi2_.id=kpi2_2_.id where device0_.id=?
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.jdbc.AbstractBatcher - preparing statement
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.type.LongType - binding '1' to parameter: 1
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.loader.Loader - processing result set
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.loader.Loader - result set row: 0
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.type.LongType - returning null as column: id3_0_
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.loader.Loader - result row: null, EntityKey[net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.loader.Loader - Initializing object from ResultSet: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.persister.entity.AbstractEntityPersister - Hydrating entity: [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.type.StringType - returning 'asdfasdf' as column: name4_1_
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.type.StringType - returning 'asdfasdf' as column: address5_1_
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.type.LongType - returning null as column: device3_
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - constructing collection load context for result set [org.apache.commons.dbcp.DelegatingResultSet@10a5314]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - starting attempt to find loading collection [[net.junisphere.eranger.domain.Device.deviceKpis#1]]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - instantiating new collection [key=1, rs=org.apache.commons.dbcp.DelegatingResultSet@10a5314]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.loader.Loader - done processing result set (1 rows)
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.jdbc.AbstractBatcher - closing statement
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.loader.Loader - total objects hydrated: 1
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - attempting to locate loading collection entry [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] in any result-set context
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - collection [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] located in load context
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - returning loading collection:[net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [net.junisphere.eranger.domain.Device#1]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - attempting to locate loading collection entry [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] in any result-set context
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.LoadContexts - collection [CollectionKey[net.junisphere.eranger.domain.Device.deviceKpis#1]] located in load context
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.loading.CollectionLoadContext - removing collection load entry [org.hibernate.engine.loading.LoadingCollectionEntry<rs=org.apache.commons.dbcp.DelegatingResultSet@10a5314, coll=[net.junisphere.eranger.domain.Device.deviceKpis#1]>@acd5d4]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections were found in result set for role: net.junisphere.eranger.domain.Device.deviceKpis
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - ending loading collection [org.hibernate.engine.loading.LoadingCollectionEntry<rs=org.apache.commons.dbcp.DelegatingResultSet@10a5314, coll=[net.junisphere.eranger.domain.Device.deviceKpis#1]>@acd5d4]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - collection fully initialized: [net.junisphere.eranger.domain.Device.deviceKpis#1]
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections initialized for role: net.junisphere.eranger.domain.Device.deviceKpis
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy collections
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.loader.Loader - done entity load
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.Cascade - processing cascade ACTION_MERGE for: net.junisphere.eranger.domain.Device
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.Cascade - cascade ACTION_MERGE for collection: net.junisphere.eranger.domain.Device.deviceKpis
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.engine.CascadingAction - cascading to merge: net.junisphere.eranger.domain.Kpi
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - mark transaction for rollback
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - rollback
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.jdbc.JDBCContext - after transaction completion
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
2010-03-04 09:39:31,671 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2010-03-04 09:39:31,671 [http-8080-1] TRACE org.hibernate.impl.SessionImpl - after transaction completion
org.springframework.orm.jpa.JpaSystemException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of net.junisphere.eranger.domain.Kpi.id; nested exception is javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of net.junisphere.eranger.domain.Kpi.id
   at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:312)
   at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:15)
   at net.junisphere.eranger.service.repository.impl.GenericRepositoryJpaImpl.update(GenericRepositoryJpaImpl.java:55)
   at net.junisphere.eranger.service.repository.impl.DeviceRepository.update(DeviceRepository.java:28)
   at net.junisphere.eranger.service.repository.impl.DeviceRepository.update(DeviceRepository.java:1)
   at net.junisphere.eranger.web.DeviceController.update(DeviceController.java:129)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
   at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
   at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
   at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:574)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:68)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:57)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
   at java.lang.Thread.run(Thread.java:619)
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of net.junisphere.eranger.domain.Kpi.id
   at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
   at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:244)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
   at $Proxy36.merge(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:224)
   at $Proxy30.merge(Unknown Source)
   ... 57 more
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of net.junisphere.eranger.domain.Kpi.id
   at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
   at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3596)
   at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:98)
   at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:687)
   at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)
   at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)
   at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
   at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
   at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
   at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
   at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
   at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
   at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
   at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
   at org.hibernate.event.def.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:407)
   at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:266)
   at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
   at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
   at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
   at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
   at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
   at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:235)
   ... 69 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field net.junisphere.eranger.domain.GenericEntity.id to java.util.LinkedHashSet
   at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
   at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
   at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
   at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
   at java.lang.reflect.Field.get(Field.java:358)
   at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
   ... 91 more


Top
 Profile  
 
 Post subject: Re: Can not set Long field foo.id to java.util.LinkedHashSet
PostPosted: Thu Mar 04, 2010 8:01 am 
Newbie

Joined: Thu Mar 04, 2010 4:46 am
Posts: 3
Forget it. Spring MVC messes up with the binding and feeds the request handler with an already corrupt Device instance, where the Set<Kpi> set does not contain KPI instances, but other Set<Kpi> sets... Hm.

Whatever. This is not a hibernate issue.


Top
 Profile  
 
 Post subject: Re: Can not set Long field foo.id to java.util.LinkedHashSet
PostPosted: Thu Mar 04, 2010 4:28 pm 
Newbie

Joined: Thu Mar 04, 2010 4:46 am
Posts: 3
The reason for this error was really hard to track down. Those that see the same error with spring MVC applications and end up here, may want to read this thread: http://forum.springsource.org/showthread.php?p=287333

Regards
James


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