Examples of DatabaseSession


Examples of oracle.toplink.sessions.DatabaseSession

    ClassLoader classLoader =
        (this.sessionClassLoader != null ? this.sessionClassLoader : ClassUtils.getDefaultClassLoader());

    // Initialize the TopLink Session, using the configuration file
    // and the session name.
    DatabaseSession session = loadDatabaseSession(this.configLocation, this.sessionName, classLoader);

    // It is possible for SessionManager to return a null Session!
    if (session == null) {
      throw new IllegalStateException(
          "A session named '" + this.sessionName + "' could not be loaded from resource [" +
          this.configLocation + "] using ClassLoader [" + classLoader + "]. " +
          "This is most likely a deployment issue: Can the class loader access the resource?");
    }

    DatabaseLogin login = (this.databaseLogin != null ? this.databaseLogin : session.getLogin());

    // Apply specified login properties to the DatabaseLogin instance.
    if (this.loginPropertyMap != null) {
      new BeanWrapperImpl(login).setPropertyValues(this.loginPropertyMap);
    }

    // Override default connection pool with specified DataSource, if any.
    if (this.dataSource != null) {
      login.setConnector(new JNDIConnector(this.dataSource));
      login.setUsesExternalConnectionPooling(true);
    }

    // Override default DatabasePlatform with specified one, if any.
    if (this.databasePlatform != null) {
      login.usePlatform(this.databasePlatform);
    }

    // Override default DatabaseLogin instance with specified one, if any.
    if (this.databaseLogin != null) {
      setDatabaseLogin(session, this.databaseLogin);
    }

    // Override default SessionLog with specified one, if any.
    if (this.sessionLog != null) {
      session.setSessionLog(this.sessionLog);
      session.logMessages();
    }

    // Log in and create corresponding SessionFactory.
    session.login();
    return newSessionFactory(session);
  }
View Full Code Here

Examples of oracle.toplink.sessions.DatabaseSession

    ClassLoader classLoader =
        (this.sessionClassLoader != null ? this.sessionClassLoader : ClassUtils.getDefaultClassLoader());

    // Initialize the TopLink Session, using the configuration file
    // and the session name.
    DatabaseSession session = loadDatabaseSession(this.configLocation, this.sessionName, classLoader);

    // It is possible for SessionManager to return a null Session!
    if (session == null) {
      throw new IllegalStateException(
          "A session named '" + this.sessionName + "' could not be loaded from resource [" +
          this.configLocation + "] using ClassLoader [" + classLoader + "]. " +
          "This is most likely a deployment issue: Can the class loader access the resource?");
    }

    DatabaseLogin login = (this.databaseLogin != null ? this.databaseLogin : session.getLogin());

    // Apply specified login properties to the DatabaseLogin instance.
    if (this.loginPropertyMap != null) {
      PropertyAccessorFactory.forBeanPropertyAccess(login).setPropertyValues(this.loginPropertyMap);
    }

    // Override default connection pool with specified DataSource, if any.
    if (this.dataSource != null) {
      login.setConnector(new JNDIConnector(this.dataSource));
      login.setUsesExternalConnectionPooling(true);
    }

    // Override default DatabasePlatform with specified one, if any.
    if (this.databasePlatform != null) {
      login.usePlatform(this.databasePlatform);
    }

    // Override default DatabaseLogin instance with specified one, if any.
    if (this.databaseLogin != null) {
      setDatabaseLogin(session, this.databaseLogin);
    }

    // Override default SessionLog with specified one, if any.
    if (this.sessionLog != null) {
      session.setSessionLog(this.sessionLog);
      session.logMessages();
    }

    // Log in and create corresponding SessionFactory.
    session.login();
    return newSessionFactory(session);
  }
View Full Code Here

Examples of oracle.toplink.sessions.DatabaseSession

    ClassLoader classLoader =
        (this.sessionClassLoader != null ? this.sessionClassLoader : ClassUtils.getDefaultClassLoader());

    // Initialize the TopLink Session, using the configuration file
    // and the session name.
    DatabaseSession session = loadDatabaseSession(this.configLocation, this.sessionName, classLoader);

    // It is possible for SessionManager to return a null Session!
    if (session == null) {
      throw new IllegalStateException(
          "A session named '" + this.sessionName + "' could not be loaded from resource [" +
          this.configLocation + "] using ClassLoader [" + classLoader + "]. " +
          "This is most likely a deployment issue: Can the class loader access the resource?");
    }

    DatabaseLogin login = (this.databaseLogin != null ? this.databaseLogin : session.getLogin());

    // Apply specified login properties to the DatabaseLogin instance.
    if (this.loginPropertyMap != null) {
      new BeanWrapperImpl(login).setPropertyValues(this.loginPropertyMap);
    }

    // Override default connection pool with specified DataSource, if any.
    if (this.dataSource != null) {
      login.setConnector(new JNDIConnector(this.dataSource));
      login.setUsesExternalConnectionPooling(true);
    }

    // Override default DatabasePlatform with specified one, if any.
    if (this.databasePlatform != null) {
      login.usePlatform(this.databasePlatform);
    }

    // Override default DatabaseLogin instance with specified one, if any.
    if (this.databaseLogin != null) {
      setDatabaseLogin(session, this.databaseLogin);
    }

    // Override default SessionLog with specified one, if any.
    if (this.sessionLog != null) {
      session.setSessionLog(this.sessionLog);
      session.logMessages();
    }

    // Log in and create corresponding SessionFactory.
    session.login();
    return newSessionFactory(session);
  }
View Full Code Here

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

Examples of org.eclipse.persistence.sessions.DatabaseSession

            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

Examples of org.eclipse.persistence.sessions.DatabaseSession

        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

Examples of org.eclipse.persistence.sessions.DatabaseSession

        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

Examples of org.eclipse.persistence.sessions.DatabaseSession

    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

Examples of org.eclipse.persistence.sessions.DatabaseSession

            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

Examples of org.eclipse.persistence.sessions.DatabaseSession

    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
TOP
Copyright © 2018 www.massapi.com. 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.