I haven't had to use the Union support so that is probably why never this seen this issue.
On Tue, Jul 29, 2014 at 1:57 PM, Lewis John Mcgibbney <lewis.mcgibb...@gmail.com> wrote: > Hi Folks, > Right now, one defines a field as follows > > {"name": "previewText", "type": ["null","string"], "default":null} > > and we generate this object using the current gora-compiler-0.5-SNAPSHOT, > then if I populate this object with either Utf8 or String then I get > ClassCastException when I attempt to cast the dirty value to ByteBuffer > within PersistentBase as follows [0]. > > private ByteBuffer getDirtyBytes() { > return (ByteBuffer) get(0); > } > > To be honest with you, the method looks rather adhoc where it is within the > class. Maybe that is only my opinion however I think that this is a bug... > or more appropriately, we could improve upon the method which would > certainly leave less owness to the developer to somehow 'know' that we are > going to cast to ByteBuffer later on. > > For example I found Alfonso's issue from a while ago [1] which essentially > describes the same thing e.g. where more flexibility should be encapsulated > so that an extended variety of text-based representations can be populated > into CharSequence field values. > > Does anyone have a comment on this one? I am really surprised that I've > only just expreienced this... in my case I am passing in a String with the > call to .setPreviewText(CharSequence char)... this results in > ClassCastException as described in [1]. > > Thanks > Lewis > > [0] > https://github.com/apache/gora/blob/master/gora-core/src/main/java/org/apache/gora/persistency/impl/PersistentBase.java#L175 > [1] https://issues.apache.org/jira/browse/GORA-189 > > > -- > *Lewis*