cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Øyvind Harboe <>
Subject Re: How to create a new datacontext based on a datacontext
Date Fri, 11 Feb 2011 10:13:29 GMT
Uhh.... injection again. Not in my repertoire as of writing :-)

I'm using this code from within a subclass of
CayenneDataObject, so I don't know who created the
DataContext that this CayenneDataObject lives in.

Can I get from a CayenneDataObject to a CayenneRuntime?

I coded up the below which allows me to create a new
DataContext with only the information in a DataContext:

	/** Duplicate code from deprecated method as we have no other way
	 * to create a new DataContext based on an existing one.
	public static DataContext createDataContext(DataContext dataContext)
		DataDomain r = dataContext.getParentDataDomain();

		DataRowStore snapshotCache = r.isSharedCacheEnabled() ?
				r.getSharedSnapshotCache() :
			new DataRowStore(r.getName(), r.getProperties(), r.getEventManager());
		DataContext context = new DataContext(r, new ObjectStore(snapshotCache));
		return context;

Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer

View raw message