When Hibernate re-writes field accesses, it doesn't check the class that the field belongs to. So if another class has the same field name as a persistent attribute, it gets re-written as well. Example:
{code} @Entity public class Parent { @Id String id; }
@Embeddable public class ChildKey { String parent; String type; }
@Entity public class Child { @EmbeddedId ChildKey id;
@MapsId("parent") @ManyToOne Parent parent;
public String shouldNotTransformIdFieldAccess() { return id.parent; } } {code} results in:
{noformat} public java.lang.String shouldNotTransformIdFieldAccess(); Code: 0: aload_0 1: invokespecial #25 // Method $$_hibernate_read_id:()Lorg/hibernate/test/bytecode/enhancement/transform/ChildKey; 4: invokespecial #29 // Method $$_hibernate_read_parent:()Lorg/hibernate/test/bytecode/enhancement/transform/Parent; 7: areturn {noformat} Line 4 should be: 4: getfield #117 // Field parent:Lorg/hibernate/test/bytecode/enhancement/transform/Parent;
|