-->
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: CompositeUserTypes containing other CompositeUserTypes
PostPosted: Tue Oct 12, 2004 11:07 am 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
I'm having a hard time finding any kind of answer to this question and was hoping HiA would flesh it out - but, alas, not even HiA went quite far enough. While HiA talks about CompositeUserTypes, it doesn't mention if a CompositeUserType can contain properties of other CompositeUserTypes. HiA uses a "MonetaryAmount" for illustration. I'll base my own example on this. Say I have created a MonetaryAmount and a MonetaryAmountCompositeUserType (just like in HiA). Now I want to create a DebitCredit type:
Code:
public class DebitCredit implements Serializable
{
  private MonetaryAmount debit;
  private MonetaryAmount credit;

  public DebitCredit(final MonetaryAmount debit, final MonetaryAmount credit)
  {
    this.debit = debit;
    this.credit = credit;
  }

  public DebitCredit() { }

  public MonetaryAmount getDebit() { return this.debit; }
  protected void setDebit(final MonetaryAmount debit) { this.debit = debit; }

  public MonetaryAmount getCredit() { return this.credit; }
  protected void setCredit(final MonetaryAmount credit) { this.credit = credit; }
}

Could I define a DebitCreditCompositeUserType for this class? If so, how? I would define two properties in my CompositeUserType ("debit" and "credit"), but Hibernate would need to reserve four fields (two fields for each MonetaryAmount). I'm not quite sure how to handle this in my nullSafeGet/nullSafeSet, or if it is even possible?

Thanks,
Anodos


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.