-->
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.  [ 1 post ] 
Author Message
 Post subject: Using the "array" sql type in an UserType
PostPosted: Fri Apr 06, 2007 5:11 pm 
Newbie

Joined: Sun Apr 09, 2006 4:57 pm
Posts: 10
Location: Milan (Italy)
As you probably know, PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any built-in or user-defined base type can be created.

Example from the PostgreSQL manual:
Code:
CREATE TABLE sal_emp (
    name text,
    pay_by_quarter integer[],
    schedule text[][]
);


I have a class with a String[] property and, for performance reasons, I'd like to write a UserType to use the array type feature to save the String[], instead of using the normal mapping of the collection on a specific table..

I red the chapter 5.3 of The Book (Java Persistence with Hibernate) but I still do not understand how to write a CompositeUserType able to map a property to something that is not an Hibernate Type. I already used the UserType feature to define some custom mapping, but I was always able to define the
Code:
public Type[] getPropertyTypes()
as an array of standard Types, as Hibernate.STRING or Hibernate.SERIALIZABLE. What can I use if the target type is an array? It must be something that implemenets the nullsafeGet and nullsafeSet methods, otherwise I could not implements those methods in my UserType.

Any hint will be appreciated.

Ciao
Marco Pancotti


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

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.