Package org.eclipse.persistence.sessions

Examples of org.eclipse.persistence.sessions.Session


            if (((ObjectLevelReadQuery) getDatabaseQuery()).setLockModeType(lockMode.name(), (AbstractSession) getActiveSession())) {
                throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null));
            }
        }
       
        Session session = getActiveSession();
        try {
            // in case it's a user-defined query
            if (getDatabaseQuery().isUserDefined()) {
                // and there is an active transaction
                if (this.entityManager.checkForTransaction(false) != null) {
                    // verify whether uow has begun early transaction
                    if (session.isUnitOfWork() && !((UnitOfWorkImpl)session).wasTransactionBegunPrematurely()) {
                        // uow begins early transaction in case it hasn't already begun.
                        // TODO: This is not good, it means that no SQL queries can ever use the cache,
                        // using isUserDefined to mean an SQL query is also wrong.
                        ((UnitOfWorkImpl)session).beginEarlyTransaction();
                    }
                }
            }
           
            // Execute the query and return the result.
            return session.executeQuery(getDatabaseQuery(), parameterValues);
        } catch (RuntimeException e) {
            setRollbackOnly();
            throw e;
        } finally {
            lockMode = null;
View Full Code Here


    public boolean isElement(Object obj) {
      if (obj instanceof JAXBElement) {
        return true;
      }
     
        Session session = context.getSession(obj);
        if(session == null) {
            return false;
        }
        XMLDescriptor descriptor = (XMLDescriptor)session.getDescriptor(obj);
        if(descriptor == null) {
            return false;
        }
       
        return descriptor.getDefaultRootElement() != null;
View Full Code Here

    protected void logoutSessions() {
        SessionManager manager = SessionManager.getManager();
        @SuppressWarnings("rawtypes")
        Map sessions = manager.getSessions();
        String orSessionName = xrService.name + DASH_STR + DBWS_OR_SESSION_NAME_SUFFIX;
        Session orSession = (Session)sessions.remove(orSessionName);
        if (orSession != null && orSession.isConnected()) {
            ((DatabaseSession)orSession).logout();
        }
        String oxSessionName = xrService.name + DASH_STR + DBWS_OX_SESSION_NAME_SUFFIX;
        sessions.remove(oxSessionName);
        xrService.orSession = null;
View Full Code Here

            return null;
        }
        if (".".equals(xPath)) {
            return (T) object;
        }
        Session session = this.getSession(object);
        XMLDescriptor xmlDescriptor = (XMLDescriptor) session.getDescriptor(object);
        StringTokenizer stringTokenizer = new StringTokenizer(xPath, XMLConstants.XPATH_SEPARATOR);
        T value = getValueByXPath(object, xmlDescriptor.getObjectBuilder(), stringTokenizer, namespaceResolver, returnType);
        if (null == value) {
            DatabaseMapping selfMapping = xmlDescriptor.getObjectBuilder().getMappingForField(new XMLField(String.valueOf(XMLConstants.DOT)));
            if (null != selfMapping && selfMapping.getReferenceDescriptor() != null) {
View Full Code Here

     * @param xPath The XPath statement
     * @param namespaceResolver A NamespaceResolver containing the prefix/URI pairings from the XPath statement.
     * @param value The value to be set.
     */
    public void setValueByXPath(Object object, String xPath, NamespaceResolver namespaceResolver, Object value) {
        Session session = this.getSession(object);
        XMLDescriptor xmlDescriptor = (XMLDescriptor) session.getDescriptor(object);
        StringTokenizer stringTokenizer = new StringTokenizer(xPath, "/");
        setValueByXPath(object, xmlDescriptor.getObjectBuilder(), stringTokenizer, namespaceResolver, value);
    }
View Full Code Here

     * @return
     *      An instance of the Java class mapped to the supplied XML type, or null
     *      if no result was found.
     */
    public <T> T createByXPath(Object parentObject, String xPath, NamespaceResolver namespaceResolver, Class<T> returnType) {
        Session session = this.getSession(parentObject);
        XMLDescriptor xmlDescriptor = (XMLDescriptor) session.getDescriptor(parentObject);
        StringTokenizer stringTokenizer = new StringTokenizer(xPath, "/");
        return createByXPath(parentObject, xmlDescriptor.getObjectBuilder(), stringTokenizer, namespaceResolver, returnType);
    }
View Full Code Here

      if (obj instanceof JAXBElement) {
        return true;
      }
     
        try {
            Session session = context.getSession(obj);
            if(session == null) {
                return false;
            }
            XMLDescriptor descriptor = (XMLDescriptor)session.getDescriptor(obj);
            if(descriptor == null) {
                return false;
            }
            return descriptor.getDefaultRootElementField() != null;
        } catch(XMLMarshalException e) {
View Full Code Here

        if (objectValue instanceof String) {
            marshalSimpleValue(xmlRootFragment, marshalRecord, originalValue, object, objectValue, session, namespaceResolver);

        } else {
            Session childSession = null;
            try {
                childSession = marshaller.getXMLContext().getSession(objectValue);
            } catch (XMLMarshalException e) {
                marshalSimpleValue(xmlRootFragment, marshalRecord, originalValue, object, objectValue, session, namespaceResolver);
                return true;
            }
            XMLDescriptor descriptor = (XMLDescriptor) childSession.getDescriptor(objectValue);
            TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder();

            List extraNamespaces = objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor, marshalRecord, session, true, true);
            if (wasXMLRoot) {
                Namespace generatedNamespace = setupFragment(((XMLRoot) originalValue), xmlRootFragment, marshalRecord);
View Full Code Here

            if (((ObjectLevelReadQuery)query).setLockModeType(lockMode.name(), (AbstractSession) getActiveSession())) {
                throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null));
            }
        }

        Session session = getActiveSession();
        try {
            // in case it's a user-defined query
            if (query.isUserDefined()) {
                // and there is an active transaction
                if (this.entityManager.checkForTransaction(false) != null) {
                    // verify whether uow has begun early transaction
                    if (session.isUnitOfWork() && !((UnitOfWorkImpl)session).wasTransactionBegunPrematurely()) {
                        // uow begins early transaction in case it hasn't
                        // already begun.
                        // TODO: This is not good, it means that no SQL queries
                        // can ever use the cache,
                        // using isUserDefined to mean an SQL query is also
                        // wrong.
                        ((UnitOfWorkImpl)session).beginEarlyTransaction();
                    }
                }
            }

            // Execute the query and return the result.
            return session.executeQuery(query, parameterValues);
        } catch (DatabaseException e) {
            // If we catch a database exception as a result of executing a
            // pessimistic locking query we need to ask the platform which
            // JPA 2.0 locking exception we should throw. It will be either
            // be a PessimisticLockException or a LockTimeoutException (if
            // the query was executed using a wait timeout value)
            if (this.lockMode != null && this.lockMode.name().contains(ObjectLevelReadQuery.PESSIMISTIC_)) {
                // ask the platform if it is a lock timeout
                if (session.getPlatform().isLockTimeoutException(e)) {
                    throw new LockTimeoutException(e);
                } else {
                    throw new PessimisticLockException(e);
                }
            } else {
View Full Code Here

                }

                List nextDOSettings = changeSummary.getOldValues(nextModifiedDO);
                DOMRecord row = new DOMRecord(csNode);
               
                Session session = ((SDOXMLHelper)typeHelper.getHelperContext().getXMLHelper()).getXmlContext().getSession(0);
                row.setSession((AbstractSession) session);

                //Iterate through SDOSettings for the current modified Object
                SDOSetting nextSetting = null;
                for (int j = 0; j < nextDOSettings.size(); j++) {
View Full Code Here

TOP

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

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.