-->
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: Customizing how references are resolved
PostPosted: Wed May 21, 2008 4:02 pm 
Newbie

Joined: Fri May 19, 2006 8:27 pm
Posts: 1
Hi,

I have the following problem. Consider Class A and B:

class Identifier
{
long id;
long effectiveFrom;
}

class PO
{
Identifier id;
long effectiveTo;
}

class A extends PO
{
String name;
B b;
}

class B extends PO
{
}

All instances have versions(not talking about the version check for optimistic locking; have deliberately kept that out of this example to avoid confusion).

So for e.g. for an id = 1 there maybe multiple rows in the table A each with a different range for (effectiveTo, effectiveFrom)

Objects have independent lifecyles and hence may version at different times.

In a Session, there is information on which version of any Object is effective. Think of this as the 'as of' date of the Session.

Given this any reference, like the reference from A to B should resolve to the effective version of B.

For e.g. consider an instance of A(id = 1, b= 2, effectiveFrom=0, effectiveTo=10000000)

For b=2 there maybe multiple rows/instances in the system. The resolution to a particular instance is based on the 'as of' Session Context.

My thoughts were that such a custom resolution could be solved by:
- PropertyAccessors; but this doesn't work because I don't have access to a Session in the Getters and Setters
- define a custom UserType. Again I don't have access to the Session.
- I was looking at EntityType. Extending OneToOneType seems a promising path; but it doesn't appear as though I can configure Hibernate to use a subtype of OneToOneType.

Anybody have thoughts/suggestions on this? Resolving based on the effectivity of a version, seems like a common problem.

regards,
Harish Butani.

PS

In case you are wondering about CRUD and Search actions. We don't expose Hibernate directly; but have a Svc layer that exposes CRUD and search actions:
- we add in the necessary conditions for Search and load. Search is only exposed through Criterias
- There is a explicit action to version an Object.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.