Package org.jpox

Examples of org.jpox.PersistenceConfiguration


                    ManagedConnection mconn;
                    public ManagedConnection retrieveConnection()
                    {
                        try
                        {
                            PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
                            if (conf.getStringProperty("org.jpox.poid.transactionAttribute").equalsIgnoreCase("UsePM"))
                            {
                                this.mconn = thisStoreMgr.getConnection(om);
                            }
                            else
                            {
                                int isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(
                                    conf.getStringProperty("org.jpox.poid.transactionIsolation"));
                                this.mconn = thisStoreMgr.getConnection(isolationLevel);
                            }
                        }
                        catch (SQLException e)
                        {
                            String msg = LOCALISER_RDBMS.msg("050024", e.getMessage());
                            JPOXLogger.POID.error(msg);
                            throw new JPOXDataStoreException(msg, e);
                        }
                        return mconn;
                    }

                    public void releaseConnection()
                    {
                        try
                        {
                            PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
                            if (conf.getStringProperty("org.jpox.poid.transactionAttribute").equalsIgnoreCase("UsePM"))
                            {
                                mconn.release();
                            }
                            else
                            {
View Full Code Here


     * @param resourceType either tx or nontx
     */
    public ConnectionFactoryImpl(OMFContext omfContext, String resourceType)
    {
        this.omfContext = omfContext;
        PersistenceConfiguration config = omfContext.getPersistenceConfiguration();

        if (resourceType.equals("tx"))
        {
            initDataSourceTx(config);
        }
View Full Code Here

        super();

        storeMgr = (RDBMSManager)store_mgr;

        // Create the auto-start table in the datastore, using any user-specified name
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        String tableName = conf.getStringProperty("org.jpox.rdbms.schemaTable.tableName");
        schemaTable = new SchemaTable(storeMgr, tableName);
        schemaTable.initialize(clr);

        // We need to autocreate the table and validate it being correct.
        try
View Full Code Here

     * @return The DataSource
     * @throws Exception Thrown if an error occurs during creation
     */
    public DataSource makePooledDataSource(OMFContext omfCtx)
    {
        PersistenceConfiguration conf = omfCtx.getPersistenceConfiguration();
        return new DriverManagerDataSource(
            conf.getStringProperty("org.jpox.ConnectionDriverName"),
            conf.getStringProperty("org.jpox.ConnectionURL"),
            conf.getStringProperty("org.jpox.ConnectionUserName"),
            conf.getStringProperty("org.jpox.ConnectionPassword"),
            omfCtx.getClassLoaderResolver(null));
    }
View Full Code Here

            qs.setParent(parentExpr);
        }
        qs.setCandidateInformation(candidateClass, candidateAlias);

        // Apply any extensions for query generation
        PersistenceConfiguration config = query.getObjectManager().getOMFContext().getPersistenceConfiguration();
        String propName = "org.jpox.rdbms.jdoql.joinType";
        String joinType = config.getStringProperty(propName);
        if (query.getExtension(propName) != null)
        {
            String type = (String)query.getExtension(propName);
            if (type.toUpperCase().equals("INNER") || type.toUpperCase().equals("LEFT OUTER"))
            {
                joinType = type.toUpperCase();
            }
        }
        if (joinType != null)
        {
            qs.addExtension(propName, joinType);
        }

        propName = "org.jpox.rdbms.jdoql.existsIncludesConstraints";
        boolean existsIncludes = config.getBooleanProperty(propName);
        if (query.getExtension(propName) != null)
        {
            existsIncludes =
                Boolean.valueOf((String)query.getExtension(propName)).booleanValue();
            qs.addExtension(propName, "" + existsIncludes);
        }
        if (existsIncludes)
        {
            qs.addExtension(propName, "true");
        }

        propName = "org.jpox.rdbms.query.containsUsesExistsAlways";
        boolean existsAlways = config.getBooleanProperty(propName);
        if (query.getExtension(propName) != null)
        {
            existsAlways =
                Boolean.valueOf((String)query.getExtension(propName)).booleanValue();
            qs.addExtension(propName, "" + existsAlways);
View Full Code Here

    protected void prepareStatementForExecution(PreparedStatement ps)
    throws SQLException
    {
        OMFContext omfCtx = om.getOMFContext();
        MappedStoreManager storeMgr = (MappedStoreManager)omfCtx.getStoreManager();
        PersistenceConfiguration conf = omfCtx.getPersistenceConfiguration();

        // Apply any user-specified timeout
        int timeout = conf.getIntProperty("org.jpox.query.timeout");
        Object timeoutExt = query.getExtension("org.jpox.query.timeout");
        if (timeoutExt != null)
        {
            // Accept timeout as an Integer or String
            if (timeoutExt instanceof Integer)
            {
                timeout = ((Integer)timeoutExt).intValue();
            }
            else if (timeoutExt instanceof String)
            {
                timeout = TypeConversionHelper.intFromString((String)timeoutExt, 0);
            }
        }
        if (timeout > 0)
        {
            ps.setQueryTimeout(timeout);
        }

        // Apply any fetch size
        int fetchSize = 0;
        if (query.getFetchPlan().getFetchSize() > 0)
        {
            // FetchPlan has a size set so use that
            fetchSize = query.getFetchPlan().getFetchSize();
        }
        if (storeMgr.getDatastoreAdapter().supportsQueryFetchSize(fetchSize))
        {
            ps.setFetchSize(fetchSize);
        }

        // Apply any fetch direction
        String propName = "org.jpox.rdbms.query.fetchDirection";
        String fetchDir = conf.getStringProperty(propName);
        Object fetchDirExt = query.getExtension(propName);
        if (fetchDirExt != null)
        {
            fetchDir = (String)fetchDirExt;
            if (!fetchDir.equals("forward") && !fetchDir.equals("reverse") && !fetchDir.equals("unknown"))
View Full Code Here

        clr = omfContext.getClassLoaderResolver(null);
    }

    public Enhancer()
    {
        this(new PersistenceConfiguration() {});
    }
View Full Code Here

        if (jdoXmlContents == null)
        {
            throw new IllegalArgumentException("Contents of file is null");
        }

        OMFContext context = new OMFContext(new PersistenceConfiguration(){});
        MetaDataManager mgr = new JDOMetaDataManager(context);
        mgr.setEnhancing();
        mgr.setMetaDataFactory(getMetaDataFactory(mgr));
        MetaDataParser parser = new MetaDataParser(mgr, true);
        JDOClassLoaderResolver clr = new JDOClassLoaderResolver();
View Full Code Here

        {
            table_name = table_name.toUpperCase();
        }

        // Utilise default catalog/schema if available and applicable
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        String catalog_name = conf.getStringProperty("org.jpox.mapping.Catalog");
        String schema_name = conf.getStringProperty("org.jpox.mapping.Schema");
        if (!dba.supportsCatalogsInTableDefinitions())
        {
            catalog_name = null;
        }
        if (!dba.supportsSchemasInTableDefinitions())
View Full Code Here

        unitMetaData = EntityManagerFactoryImpl.unitMetaDataCache.get(unitName);
        if (unitMetaData == null)
        {
            // Find all "META-INF/persistence.xml" files in the current thread loader CLASSPATH and parse them
            // Create a temporary PMFContext so we have a parser
            OMFContext pmfCtxt = new OMFContext(new PersistenceConfiguration(){});
            pmfCtxt.setApi("JPA");
            MetaDataManager metadataMgr = pmfCtxt.getMetaDataManager();
            PersistenceFileMetaData[] files = metadataMgr.parsePersistenceFiles();
            if (files == null)
            {
View Full Code Here

TOP

Related Classes of org.jpox.PersistenceConfiguration

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.