-->
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.  [ 3 posts ] 
Author Message
 Post subject: Handling subclasses of persistent classes
PostPosted: Mon Dec 26, 2005 10:51 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
b]Hibernate version:[/b] 3.1

Can Hibernate persist a subclass of a persistent class, where the subclass is not explicitly mapped or described to hibernate, but it's superclass is?

We are considering a proxying approach where we manually substitue "smart" subclasses of a persistent class when we send them to a remote (rich) client. When these "smart" subclasses come back, we would need them to be persistable.

Example:

Code:

class A {
  String foo;
  /* @hibernate.blah.blah */
  public String getFoo() {...}
  public void setFoo(String s) {...}
}

class SmartA extends A {
  String fooID;
  A underlyingObject = null;

  public String getFoo() {
     if (A==null)
         retrieveObjectFromServer(fooID)
     return A.getFoo();
  }
}



We want to replace A with SmartA to avoid sending the whole object graph to the client but if A is set on the client or modified, we want the saving, cascade-dirty checks to all work as normal.

Is this approach sound?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no - not very sound.

why not just only load the part of the objectgraph you actually want to send ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 5:34 pm 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
Thanks for the help. One reason for our approach is caching.

If we bring back initial data for object X, and then need to get a bit more data X.getDetails() we'd rather extend the existing graph to include the details rather than re-retrieve X with Details. (Note we have a rich client application, so we have to incur significant overhead to go get a network of objects.)

Also, we can't figure out how to cache objects if we're going to have multiple copies retreived by different processes.


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