[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5255) Bytecode instrumented byte[] lazy properties do not work
Kyrill Alyoshin (JIRA)
noreply at atlassian.com
Mon Jul 12 00:18:14 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37708#action_37708 ]
Kyrill Alyoshin commented on HHH-5255:
--------------------------------------
The way I worked around it was by creating a custom wrapper class around the raw byte[] and by supporting it through a custom Hibernate UserType to store and retrieve it. Much more elegant solution in my opinion.
> Bytecode instrumented byte[] lazy properties do not work
> --------------------------------------------------------
>
> Key: HHH-5255
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5255
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.2
> Environment: Hibernate-3.5.2, Oracle 10g
> Reporter: Kyrill Alyoshin
>
> 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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list