What is the purpose and exected value of getPropertyType, getPropertyValue and setPropertyValue in CompositeUserType?
I am trying to implement a CompositeUserType that encapsulates a multimedia object. This MediaObject contains two fields:
- contenttype (Java 5 Enum)
- data (byte[]).
The database schema also contains two columns:
- contenttype (varchar)
- data (blob)
Notice, that MediaObject's types are not the same type as database columns. The content-type is converted to a varchar using 'toString' and the data is operated on as a byte[] as opposed to the Blob. [Blob vs byte[] is important - I do not want to operate on Blobs in the model, since it both defeats the caching mechanism in Hibernate and prevents using of buffered fetch.]
It is pretty straightforward to implement custom UserType for either one of these columns - but combining them into a single CompositeUserType stumps me.
What should the getPropertyType return? { Types.VARCHAR, Types.BLOB } Or should it be { Types.VARCHAR, Types.BINARY }? (I am guessing that is is the former, since Types.BINARY would map to VARBINARY, which is limited in size. On the other hand, JDBC operates on VARBINARY using byte[] instead of Blob, which is what I want...)
What are the types of objects passed to getPropertyValue/setPropertyValue (I assume these functions use the same type for 'get' and 'set'?) Is it String and Blob? Is it Enum and byte[]?
In general, what is the purpose of getPropertyType, getPropertyValue, and setPropertyValue? There are other dedicated methods for reading/writing the type to the second-level cache or to JDBC...
[I realize that an alternative to using CompositeUserType is to implement two separate UserTypes and use component. For variety of reasons that solution would not work in my case.]
TIA,
Alik
|