Package org.eclipse.persistence.sessions

Examples of org.eclipse.persistence.sessions.DatabaseSession


        setXMLContext(xmlContext);
        initialize();     
    }

    private void initialize() {
        DatabaseSession session = xmlContext.getSession(0);
        XMLPlatform xmlPlatform = (XMLPlatform)session.getDatasourceLogin().getDatasourcePlatform();
        platformUnmarshaller = xmlPlatform.newPlatformUnmarshaller(this);
        platformUnmarshaller.setWhitespacePreserving(false);
        unmarshalProperties = new Properties();

        // Waiting on XDK to fix bug #3697940 to enable this code
View Full Code Here


            XMLPlatform platform = new SAXPlatform();
            platform.getConversionManager().setLoader(classLoader);
            project.setLogin(new XMLLogin(platform));
        }
        sessions = new ArrayList(1);
        DatabaseSession session = project.createDatabaseSession();

        // turn logging for this session off and leave the global session up
        // Note: setting level to SEVERE or WARNING will printout stacktraces for expected exceptions
        session.setLogLevel(SessionLog.OFF);
        // dont turn off global static logging
        //AbstractSessionLog.getLog().log(AbstractSessionLog.INFO, "ox_turn_global_logging_off", getClass());             
        //AbstractSessionLog.getLog().setLevel(AbstractSessionLog.OFF);
        setupDocumentPreservationPolicy(session);
        session.login();
        sessions.add(session);
        descriptorsByQName = new HashMap();
        descriptorsByGlobalType = new HashMap();
        storeXMLDescriptorsByQName(session);
    }
View Full Code Here

        if ((project.getDatasourceLogin() == null) || !(project.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
          XMLPlatform platform = new SAXPlatform();
          platform.getConversionManager().setLoader(classLoader);
          project.setLogin(new XMLLogin(platform));
        }
        DatabaseSession session = project.createDatabaseSession();

        // turn logging for this session off and leave the global session up
        // Note: setting level to SEVERE or WARNING will printout stacktraces for expected exceptions
        session.setLogLevel(SessionLog.OFF);
        // dont turn off global static logging
        //AbstractSessionLog.getLog().log(AbstractSessionLog.INFO, "ox_turn_global_logging_off", getClass());             
        //AbstractSessionLog.getLog().setLevel(AbstractSessionLog.OFF);
        setupDocumentPreservationPolicy(session);
        session.login();
        sessions.add(session);
        storeXMLDescriptorsByQName(session);
      }
    }
View Full Code Here

        storeXMLDescriptorsByQName(session);
      }
    }
   
    private DatabaseSession buildSession(String sessionName, ClassLoader classLoader, XMLSessionConfigLoader sessionLoader) throws XMLMarshalException {
        DatabaseSession dbSession;
        if (classLoader != null) {
            dbSession = (DatabaseSession) SessionManager.getManager().getSession(sessionLoader, sessionName, classLoader, false, true);
        } else {
            dbSession = (DatabaseSession) SessionManager.getManager().getSession(sessionLoader, sessionName, PrivilegedAccessHelper.privilegedGetClassLoaderForClass(this.getClass()), false, false, false);
        }
        if ((dbSession.getDatasourceLogin() == null) || !(dbSession.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
            XMLPlatform platform = new SAXPlatform();
            dbSession.setLogin(new XMLLogin(platform));
        }
        DatabaseSession session = dbSession.getProject().createDatabaseSession();
        if (dbSession.getEventManager().hasListeners()) {
            List listeners = dbSession.getEventManager().getListeners();
            int listenersSize = listeners.size();
            for (int x = 0; x < listenersSize; x++) {
                session.getEventManager().addListener((SessionEventListener) listeners.get(x));
            }
        }
        session.setExceptionHandler(dbSession.getExceptionHandler());
        session.setLogLevel(SessionLog.OFF);
        setupDocumentPreservationPolicy(session);
        session.login();
        return session;
    }
View Full Code Here

    public void addSession(DatabaseSession sessionToAdd) {
        if ((sessionToAdd.getDatasourceLogin() == null) || !(sessionToAdd.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
            XMLPlatform platform = new SAXPlatform();
            sessionToAdd.setLogin(new XMLLogin(platform));
        }
        DatabaseSession session = sessionToAdd.getProject().createDatabaseSession();
        if (sessionToAdd.getEventManager().hasListeners()) {
            List listeners = sessionToAdd.getEventManager().getListeners();
            int listenersSize = listeners.size();
            for (int x = 0; x < listenersSize; x++) {
                session.getEventManager().addListener((SessionEventListener) listeners.get(x));
            }
        }
        session.setExceptionHandler(sessionToAdd.getExceptionHandler());
        session.setLogLevel(SessionLog.OFF);
        this.setupDocumentPreservationPolicy(session);
        session.login();
        sessions.add(session);

        storeXMLDescriptorsByQName(session);

    }
View Full Code Here

            return null;
        }

        final org.eclipse.persistence.jaxb.JAXBContext moxyJaxbContext = JAXBHelper.getJAXBContext(jaxbContext);
        final XMLContext xmlContext = moxyJaxbContext.getXMLContext();
        final DatabaseSession session = xmlContext.getSession(0);

        Class<?> expectedType = this.expectedType;
        if (!isRoot) {
            final HashMap<Type, QName> typeToSchemaType = moxyJaxbContext.getTypeToSchemaType();

            for (Map.Entry<Type, QName> entry : typeToSchemaType.entrySet()) {
                if (entry.getValue().getLocalPart().equals(elementName.getLocalPart())) {
                    expectedType = (Class<?>) entry.getKey();
                    break;
                }
            }
        }

        if (JAXBElement.class.isAssignableFrom(expectedType)) {
            final Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

            for (Map.Entry<Class, ClassDescriptor> descriptor : descriptors.entrySet()) {
                final QName defaultRootElementType = ((XMLDescriptor) descriptor.getValue()).getDefaultRootElementType();

                // Check local name.
                if (defaultRootElementType == null
                        || !defaultRootElementType.getLocalPart().contains(elementName.getLocalPart())) {
                    continue;
                }

                // Check namespace.
                if ((defaultRootElementType.getNamespaceURI() == null && elementName.getNamespaceURI() == null)
                        || (defaultRootElementType.getNamespaceURI() != null
                            && defaultRootElementType.getNamespaceURI().equals(elementName.getNamespaceURI()))) {
                    expectedType = descriptor.getKey();
                }
            }
        }

        final ClassDescriptor descriptor = session.getDescriptor(expectedType);

        if (descriptor != null) {
            final TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder();

            return new XPathNodeWrapper(objectBuilder.getRootXPathNode(),
View Full Code Here

    DBAccessorImpl dbAccessor = injector.getInstance(DBAccessorImpl.class);
    String tableName = getFreeTableName();
    createMyTable(tableName);
    dbAccessor.executeQuery("insert into " + tableName + "(id, name, time) values(1, 'Bob', 1234567)");

    DatabaseSession databaseSession = dbAccessor.getNewDatabaseSession();
    databaseSession.login();
    Vector vector = databaseSession.executeSQL("select * from " + tableName + " where id=1");
    assertEquals(vector.size(), 1);
    Map map = (Map) vector.get(0);
    //all names seem to be converted to upper case
    assertEquals("Bob", map.get("name".toUpperCase()));

    databaseSession.logout();
  }
View Full Code Here

                if ((project.getDatasourceLogin() == null) || !(project.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
                    XMLPlatform platform = new SAXPlatform();
                    platform.getConversionManager().setLoader(classLoader);
                    project.setLogin(new XMLLogin(platform));
                }
                DatabaseSession session = project.createDatabaseSession();

                // turn logging for this session off and leave the global session up
                // Note: setting level to SEVERE or WARNING will printout stacktraces for expected exceptions
                session.setLogLevel(SessionLog.OFF);
                // don't turn off global static logging
                //AbstractSessionLog.getLog().log(AbstractSessionLog.INFO, "ox_turn_global_logging_off", getClass());
                //AbstractSessionLog.getLog().setLevel(AbstractSessionLog.OFF);
                setupDocumentPreservationPolicy(session);
                session.login();
                sessions.add(session);
                storeXMLDescriptorsByQName(session);
            }
        }
View Full Code Here

                XMLPlatform platform = new SAXPlatform();
                platform.getConversionManager().setLoader(classLoader);
                project.setLogin(new XMLLogin(platform));
            }
            sessions = new ArrayList(1);
            DatabaseSession session = project.createDatabaseSession();
           
            // if an event listener was passed in as a parameter, register it with the event manager
            if (sessionEventListener != null) {
                session.getEventManager().addListener(sessionEventListener);
            }

            // turn logging for this session off and leave the global session up
            // Note: setting level to SEVERE or WARNING will printout stacktraces for expected exceptions
            session.setLogLevel(SessionLog.OFF);
            // don't turn off global static logging
            //AbstractSessionLog.getLog().log(AbstractSessionLog.INFO, "ox_turn_global_logging_off", getClass());
            //AbstractSessionLog.getLog().setLevel(AbstractSessionLog.OFF);
            setupDocumentPreservationPolicy(session);

            session.login();
            sessions.add(session);
            descriptorsByQName = new HashMap();
            descriptorsByGlobalType = new HashMap();
            storeXMLDescriptorsByQName(session);
        }
View Full Code Here

        private void addSession(DatabaseSession sessionToAdd) {
            if ((sessionToAdd.getDatasourceLogin() == null) || !(sessionToAdd.getDatasourceLogin().getDatasourcePlatform() instanceof XMLPlatform)) {
                XMLPlatform platform = new SAXPlatform();
                sessionToAdd.setLogin(new XMLLogin(platform));
            }
            DatabaseSession session = sessionToAdd.getProject().createDatabaseSession();
            if (sessionToAdd.getEventManager().hasListeners()) {
                List listeners = sessionToAdd.getEventManager().getListeners();
                int listenersSize = listeners.size();
                for (int x = 0; x < listenersSize; x++) {
                    session.getEventManager().addListener((SessionEventListener) listeners.get(x));
                }
            }
            session.setExceptionHandler(sessionToAdd.getExceptionHandler());
            session.setLogLevel(SessionLog.OFF);
            this.setupDocumentPreservationPolicy(session);
            session.login();
            sessions.add(session);

            storeXMLDescriptorsByQName(session);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.sessions.DatabaseSession

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.