-->
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: Mapping Map Attribute
PostPosted: Tue Nov 08, 2005 8:38 pm 
Newbie

Joined: Tue Nov 08, 2005 8:31 pm
Posts: 5
Hello!

i have a non-normalized table structure like this:

Table XXX
ID INTEGER,
DESC VARCHAR,
12_MONTHS_TAX INTEGER(10,2),
24_MONTHS_TAX INTEGER(10,2),
36_MONTHS_TAX INTEGER(10,2)

I would like to map this structure for something like this class:


class XXX {

Long id;
String desc;
Map taxes;

}

where taxes map attribute keys are 12_MONTHS_TAX, 24_MONTHS_TAX and 36_MONTHS_TAX

Is that possible?

Thanks


Top
 Profile  
 
 Post subject: Alternative suggestion
PostPosted: Tue Nov 08, 2005 9:21 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
A quick look through the documentation didn't turn up anything like what you're describing. If you're willing to drop the map idea in favour of a component, that would be pretty close to what you want. You would end up with a class like

Code:
class XXX
{
  Long id;
  String desc;
  Taxes taxes;

  public class Taxes
  {
    int monthsTwelve;
    int monthsTwentyFour;
    int monthsThritySix;
  }
}



To do this, add something like this inside your XXX mapping:

Code:
  <property ...>
  ...
  <component name="taxes" class="com.me.XXX.Taxes">
    <property name="MonthsTwelve" type="integer"/>
    ...
  </component>


Is that close enough to what you want? Note that the Taxes class doesn't have to be inside the XXX class. In fact, I'm not even sure if it allowed to be a nested class. I've only ever used normal classes for this sort of thing.


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.