cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: How to get domain from context
Date Wed, 02 Sep 2009 07:54:11 GMT
Hi akira,

If you need explicit access to the domain, you will have to cast you  
ObjectContext to DataContext and use 'getParentDataDomain':

DataDomain domain = ((DataContext) context).getParentDataDomain();

Andrus

On Sep 2, 2009, at 10:45 AM, akira wrote:

> Hi, i'm getting my context this way: ObjectContext context =  
> DataContext.getThreadObjectContext(). How to know the domain that  
> the context is using? If i get context as a DataContext type i can  
> obtain the domain using : getParentDataDomain().getName() right? On  
> my app i have to change the domain under certain circumstancies and  
> on my code i'm trying to do something like this:
> ObjectContext context = DataContext.getThreadObjectContext()
> if (context.getDomain() == domainToQueryNow) {
> return context;
> } else {
> DataContext.createDataContext(domainToQueryNow);
> }
>
> TIA.


Mime
View raw message