-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: What is the purpose of PropertyValue in CompositeUserType
PostPosted: Wed Jun 15, 2005 5:24 am 
Newbie

Joined: Wed Jun 15, 2005 4:58 am
Posts: 6
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 5:28 am 
Newbie

Joined: Wed Jun 15, 2005 4:58 am
Posts: 6
Errr... I meant to use { Hibernate.STRING, Hibernate.BLOB } when talking about getPropertyTypes. Sorry...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.