Hibernate map a class as another one



I am trying to map a class which looks like:



public class Skills {
private int[] levels; // 10 elements
}


Now, mapping an array in Hibernate is a big pain and as I had no luck at all doing that before, I am trying a different approach. Each and every of the 10 elements, actually represents a skill itself. Think of it as ATK, STR, DEX, INT, et cetera. Due to a few design restrictions, it has to be used as an array, otherwise I'd simply add 10 fields to it, of course.


The real pain is in mapping that in SQL to make more sense. Sure, Hibernate can do Serialization of the class but that drills bytes into columns. Now I wonder, is there any way to specify something like CompoundUserType (me being able to say "hey, this is how the table will look, and this is each value of the field!"), or indicate that I in some way want to provide a Skills$Hbm subclass which contains something along



class Hbm {
private int atk, str, dex, Int... ;
}


to let me get a nicer table? I'm pretty clueless on what a viable approach can be.


No comments:

Post a Comment