Package org.apache.cayenne.access

Examples of org.apache.cayenne.access.DataContext


        }
    }

    public void testToManyTargetDifferentContext() throws Exception {
        DataContext context1 = createDataContext();
        Painting doC1 = context1.newObject(Painting.class);

        DataContext context2 = createDataContext();
        Artist doC2 = context2.newObject(Artist.class);

        // this is the case where exception must be thrown as DataContexts are
        // different
        try {
            doC2.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, doC1, false);
View Full Code Here


    protected DataContext getDataContext() {
        try {
            return (DataContext) BaseContext.getThreadObjectContext();

        } catch (IllegalStateException ise) {
            DataContext dataContext = DataContext.createDataContext();
            BaseContext.bindThreadObjectContext(dataContext);
            return dataContext;
        }
    }
View Full Code Here

        if (request instanceof HttpServletRequest) {
            reset = true;

            HttpSession session = ((HttpServletRequest) request).getSession(true);
            DataContext context = ServletUtil.getSessionContext(session);
            DataContext.bindThreadDataContext(context);
        }

        try {
            chain.doFilter(request, response);
View Full Code Here

    protected DataContext getDataContext() {
        try {
            return (DataContext) BaseContext.getThreadObjectContext();

        } catch (IllegalStateException ise) {
            DataContext dataContext = DataContext.createDataContext();
            BaseContext.bindThreadObjectContext(dataContext);
            return dataContext;
        }
    }
View Full Code Here

        ServerRuntime runtime = new ServerRuntime("Yuis", module);
        assertSame(channel, runtime.getChannel());
    }

    public void testGetObjectContext_CustomModule() {
        final ObjectContext context = new DataContext();
        final ObjectContextFactory factory = new ObjectContextFactory() {

            public ObjectContext createContext(DataChannel parent) {
                return context;
            }
View Full Code Here

                .getSharedSnapshotCache() : new DataRowStore(
                dataDomain.getName(),
                dataDomain.getProperties(),
                eventManager);

        DataContext context = new DataContext(
                parent, objectStoreFactory.createObjectStore(snapshotCache));
        context.setValidatingObjectsOnCommit(dataDomain.isValidatingObjectsOnCommit());
        context.setQueryCache(new NestedQueryCache(queryCache));
        return context;
    }
View Full Code Here

    protected ObjectContext createFromDataContext(DataContext parent) {
        // child ObjectStore should not have direct access to snapshot cache, so do not
        // pass it in constructor.
        ObjectStore objectStore = objectStoreFactory.createObjectStore(null);

        DataContext context = new DataContext(parent, objectStore);

        context.setValidatingObjectsOnCommit(parent.isValidatingObjectsOnCommit());
        context.setUsingSharedSnapshotCache(parent.isUsingSharedSnapshotCache());
        context.setQueryCache(new NestedQueryCache(queryCache));

        return context;
    }
View Full Code Here

        // it makes it easier to track the event subject
        DataRowStore snapshotCache = (parent.isSharedCacheEnabled()) ? parent
                .getSharedSnapshotCache() : new DataRowStore(parent.getName(), parent
                .getProperties(), eventManager);

        DataContext context = new DataContext(
                parent, objectStoreFactory.createObjectStore(snapshotCache));
        context.setValidatingObjectsOnCommit(parent.isValidatingObjectsOnCommit());
        context.setQueryCache(new NestedQueryCache(queryCache));
        return context;
    }
View Full Code Here

  @Override
  protected Void doInBackground() throws Exception {
    publish("Loading connection");

    DataContext context = DataContext.createDataContext();

    controller.getLibraryManager().setContext(context);
   
    publish("Initiailizing library manager");
View Full Code Here

        if (request instanceof HttpServletRequest) {
            reset = true;

            HttpSession session = ((HttpServletRequest) request).getSession(true);
            DataContext context = ServletUtil.getSessionContext(session);
            BaseContext.bindThreadObjectContext(context);
        }

        try {
            chain.doFilter(request, response);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.access.DataContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.