-->
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.  [ 4 posts ] 
Author Message
 Post subject: composite-key and primitive-array mapping
PostPosted: Wed Jun 06, 2007 11:29 am 
Newbie

Joined: Sat Feb 25, 2006 9:56 am
Posts: 6
Basically I need something like a discriminator for arrays, because all arrays of ints need to be in one table. so if a class has two properties that both are arrays of ints I need to tell them apart.

I figured I would setup my table like this

intarray
id //class_id
property_name //name of property in class
value // int value
index // array index

However I can't figure out how to write the mapping for this. It doesn't need to exactly like this but all int arrays need to be in the same table.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 2:52 pm 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
Did you try using the where keyword on your collections? That should cause it to be filtered for you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 12:56 am 
Newbie

Joined: Sat Feb 25, 2006 9:56 am
Posts: 6
The where will work for retrieving them, but is not going to help with inserts


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 7:43 am 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
jebus wrote:
The where will work for retrieving them, but is not going to help with inserts


Ok, this is fair enough. To answer that then, I say don't map just a type of integers. Instead map your own type. Maybe you could even do something like this MyType<Int32>. Have a generic type with the properties which you need to manage the collection. Have a PropertName on the MyType class. Have a value property on there as well which is of the generic type. You could then map that type and have a collection of value types containing integers. This way it is somewhat close to what you want. You still have value type semantics, and you can use it with all of your types (integers, floating points, etc). You could still use the where clause for the retrieval, you'll just be responsible for setting the property name on the new type.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.