-->
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: Wrapped collection in persistent object
PostPosted: Fri Aug 12, 2011 1:33 pm 
Newbie

Joined: Fri Aug 12, 2011 1:20 pm
Posts: 5
Hi!

I have following case:
Persistent object A contains property (lets name it 'prop') which is of class that implements Set, but actually it is a wrapper. How should I map it? I cannot use direct collection mapping, because hibernate proxy will not do what my wrapper does (hibernate proxy should be wrapped by my wrapper). Should I use CustomType or custom PropertyAccessor or something else? I just don't know where to start :). I've tried to google, but I've found only one suggestion that maybe PropertyAccessor would be good...

Thanks in advance!
Best regards,
R;


Top
 Profile  
 
 Post subject: Re: Wrapped collection in persistent object
PostPosted: Mon Aug 15, 2011 6:52 pm 
Newbie

Joined: Fri Aug 12, 2011 1:20 pm
Posts: 5
Hi again, how to map this kind of domain model:

Code:
class Person
{
  private String name;
  private String surname;
  private Children children;
}

class Children extends AbstractSet<Child> implements Set<Child>
{
  private Set<Child> underlyingSet = new HashSet<Child>();

  public Child giveBirth()
  {
    underlyingSet.add(new Child());
  }

  public boolean add(Child child)
  {
     throw new UnsupportedOperationException("Use giveBirth()");
  }
 
  [...]
}


The main problem here is that Person-Child is an 1-N association, however non-standard collection container is used, so proxy won't fit. How to map this not breaking the model by addition of some "special" setters/getters and stuff like this. I would like to keep "transparent persistency" as much as possible...

Anybody?

Thanks in advance!
rafi


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.