-->
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: Persisting a map of key/value pairs
PostPosted: Wed Dec 14, 2005 5:56 am 
Newbie

Joined: Sun Dec 11, 2005 3:18 am
Posts: 2
I'm fairly new to all this and am having a conceptual problem. I've been wading through documentation, but I'm not even sure where I'm supposed to be looking anymore :S

I had an idea that if I use a base class as below, then users could subclass it for there own logic (storing all data in the map rather than instance variables), and hibernate would be able to persist it without changing the DB structure using a single_table inheritance strategy.

1) Is this idea valid?
2) What association is needed to persist the map? It's a component, right? I was thinking a schema along these lines:
Discount
- Id
DiscountParameter
- DiscountId (foreign key to Discount)
- Key
- Value

I've tried a heap of different things, but can't quite get my head around how OneToMany or ManyToMany relates to this situation.

Thanks,
- Xavier

Hibernate version:
3.1rc2
Mapping documents:
Code:
@Entity
@Inheritance(
    strategy=InheritanceType.SINGLE_TABLE,
    discriminatorType=DiscriminatorType.STRING,
    discriminatorValue="discountType"
)
public abstract class Discount {
   private Long id;
   private Map<String, String> parameters;
   
    @????
   public Map<String, String> getParameters() {
      return parameters;
   }

   public void setParameters(Map<DiscountKey, DiscountValue> parameters) {
      this.parameters = parameters;
   }

   @Id
   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

public abstract getDiscountAmount(...);
}


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.