Uploaded image for project: 'Hibernate ORM'
  1. HHH-5255

Merge detached entity failed when the instrumented lazy property is initialized

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.5.2, 4.3.8
    • Fix Version/s: 5.0.0.CR3, 4.3.11, 4.2.21
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Hibernate-3.5.2, Oracle 10g
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Well, I have an entity that stores a byte[] property as a Blob.

      @Lob
      @Basic(optional = false, fetch = FetchType.LAZY)
      public byte[] getContent() {
      return content;
      }

      The content can be pretty large, so I marked it as lazy and to enable lazy property fetching I am instrumenting the class at build-time using org.hibernate.tool.instrument.javassist.InstrumentTask just as the documentation says.

      However, when I call session.merge on this entity, I can get this stacktrace:

      java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B
      at org.hibernate.type.AbstractLongBinaryType.toInternalFormat(AbstractLongBinaryType.java:46)
      at org.hibernate.type.AbstractBynaryType.isEqual(AbstractBynaryType.java:134)
      at org.hibernate.type.NullableType.isEqual(NullableType.java:233)
      at org.hibernate.type.MutableType.replace(MutableType.java:60)
      at org.hibernate.type.TypeFactory.replace(TypeFactory.java:548)
      at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:495)
      at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:423)
      at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:234)
      at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
      at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:859)
      at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:843)
      at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:847)

      It seems to work fine on session.get()

      I think it is a bug.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                7 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: