-->
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.  [ 2 posts ] 
Author Message
 Post subject: cascade delete problem with byte-code instrumentation
PostPosted: Fri Nov 30, 2012 11:03 am 
Newbie

Joined: Sun Aug 28, 2005 1:29 pm
Posts: 12
I have two entity classes which are byte-code instrumented: Person and Address. A person has an optional one-to-one address. The PK of the Address class is the FK of Person.

Code:
@Entity
public class Person {
...
  @OneToOne(mappedBy = "person", cascade = ALL, orphanRemoval = true)
  @LazyToOne(LazyToOneOption.NO_PROXY)
  @PrimaryKeyJoinColumn
  private Address address;
...
}

@Entity
public class Address {
...
   @Id
    private Long id;

    @MapsId
    @OneToOne
    private Person person;
...
}


When I attempt to delete a Person record, I get the following error:

Quote:
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of Person.id
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:62) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:341) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4323) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:65) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.internal.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:107) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.internal.SessionImpl.fireDelete(SessionImpl.java:954) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:939) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:262) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:165) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.internal.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:324) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.internal.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:263) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.internal.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:161) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.internal.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.internal.SessionImpl.fireDelete(SessionImpl.java:946) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:925) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
...
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field Person.id to org.hibernate.bytecode.instrumentation.spi.LazyPropertyInitializer$1
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) ~[na:1.7.0_02]
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) ~[na:1.7.0_02]
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:55) ~[na:1.7.0_02]
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36) ~[na:1.7.0_02]
at java.lang.reflect.Field.get(Field.java:372) ~[na:1.7.0_02]
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:59) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]


If I remove the byte-code instrumentation, the cascaded delete works as expected.

Any ideas about what I might be doing wrong?

Thanks
Andrew


Top
 Profile  
 
 Post subject: Re: cascade delete problem with byte-code instrumentation
PostPosted: Mon Jul 29, 2013 3:28 pm 
Newbie

Joined: Mon Jul 29, 2013 3:27 pm
Posts: 1
Did you find a solution?


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