Package org.apache.openjpa.jdbc.meta

Examples of org.apache.openjpa.jdbc.meta.MappingRepository


     */
    private void setPersistenceCapableParameter(Map<Integer,Object> result,
        Object pc, int[] indices, Broker broker) {
        JDBCStore store = (JDBCStore)broker.getStoreManager()
            .getInnermostDelegate();
        MappingRepository repos = store.getConfiguration()
            .getMappingRepositoryInstance();
        ClassMapping mapping = repos.getMapping(pc.getClass(),
            broker.getClassLoader(), true);
        Column[] pks = mapping.getPrimaryKeyColumns();
        Object cols = mapping.toDataStoreValue(pc, pks, store);
        if (cols instanceof Object[]) {
            Object[] array = (Object[])cols;
View Full Code Here


            String resultMapping = ctx.getResultMappingName();
            if (resultMapping == null)
                _resultMapping = null;
            else {
                ClassLoader envLoader = ctx.getStoreContext().getClassLoader();
                MappingRepository repos = q.getStore().getConfiguration().
                    getMappingRepositoryInstance();
                _resultMapping = repos.getQueryResultMapping
                    (ctx.getResultMappingScope(), resultMapping, envLoader,
                        true);
            }
            _meta = candidate;
View Full Code Here

        OpenJPAEntityManager pm = pmf.createEntityManager();
        JDBCConfiguration con =
            (JDBCConfiguration) ((OpenJPAEntityManagerSPI) pm)
            .getConfiguration();
        DBDictionary dict = con.getDBDictionaryInstance();
        MappingRepository repos = con.getMappingRepositoryInstance();
        ClassMapping cm = repos.getMapping(RuntimeTest1.class,
                pm.getClassLoader(), true);
        String schemas = cm.getTable().getSchema().getName();
        if (schemas == null)
            schemas = "";
        schemas += "." + cm.getTable().getName();
View Full Code Here

     * Tests that application identity classes are returned correctly.
     */
    public void testSchemaGeneration() {
        JDBCConfiguration conf = new JDBCConfigurationImpl();
        DBDictionary dict = conf.getDBDictionaryInstance();
        MappingRepository repos = conf.getMappingRepositoryInstance();
        repos.setStrategyInstaller(new RefreshStrategyInstaller(repos));
        ClassMapping mapping = repos.getMapping(Column.class, null, true);

        Class cls;
        if (dict.getPreferredType(JavaSQLTypes.CLOB) ==  JavaSQLTypes.CLOB) {
            if (dict.maxEmbeddedClobSize > 0) {
                cls = mapping.getFieldMapping("toClob").getStrategy().
                    getClass();
                assertTrue(cls.getName(),
                    MaxEmbeddedClobFieldStrategy.class.isAssignableFrom(cls));
            } else {
                cls = mapping.getFieldMapping("toClob").getHandler().
                    getClass();
                assertTrue(cls.getName(),
                    ClobValueHandler.class.isAssignableFrom(cls));
            }
        } else
            assertTrue(mapping.getFieldMapping("toClob").getStrategy()
                instanceof StringFieldStrategy);

        cls = mapping.getFieldMapping("toBlob").getHandler().getClass();
        assertTrue(cls.getName(),
            BlobValueHandler.class.isAssignableFrom(cls));

        SchemaGroup schema = repos.getSchemaGroup();
        Table table = schema.getSchemas()[0].getTables()[0];
        Column[] cols = table.getColumns();
        for (int i = 0; i < cols.length; i++) {
            if (cols[i].getName().equalsIgnoreCase("id")
                || cols[i].getName().equalsIgnoreCase("versn")
View Full Code Here

    public void setUp()
        throws Exception {
        JDBCConfiguration conf = new JDBCConfigurationImpl();
        conf.setSchemaFactory(DynamicSchemaFactory.class.getName());
        MappingRepository repos = conf.newMappingRepositoryInstance();
        _mapping = repos.getMapping(MappingTest1.class, null, true);
    }
View Full Code Here

     * This test does not take into account and DB specific reserved words and
     * can be run with any DBDictionary.
     * </P>
     */
    public void testSQLKeywords() {
        MappingRepository repos =
                (MappingRepository) emf.getConfiguration()
                        .getMetaDataRepositoryInstance();

        assertEquals("SELECT_ID", repos.getMapping(Inner1.class, null, true)
                .getFieldMapping("select").getColumns()[0].getName());

        assertEquals("FROM_ID", repos.getMapping(Inner2.class, null, true)
                .getFieldMapping("from").getColumns()[0].getName());
    }
View Full Code Here

            ? null : relMapping.getDiscriminator();
        ClassMapping mapping = null;
        Joins joins = pathState.joins;
        if (discrim != null) {
            // cache mapping for cast
            MappingRepository repos = ctx.store.getConfiguration().
                getMappingRepositoryInstance();
            mapping = repos.getMapping(_cls, ctx.store.getContext().
                getClassLoader(), false);

            // if not looking for a PC, don't bother with indicator
            if (mapping == null || !discrim.hasClassConditions(mapping, true))
                discrim = null;
View Full Code Here

//        assertEquals(0, cls.getDiscriminator().getColumns().length);
//    }

    public void testJoinedDiscriminatorWithColumn() {
        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
        MappingRepository repo = conf.getMappingRepositoryInstance();
        ClassMapping cls = repo.getMapping(AnnoTest1.class,
            null, true);
        assertTrue(cls.getDiscriminator().getStrategy()
            instanceof ValueMapDiscriminatorStrategy);
        assertEquals(1, cls.getDiscriminator().getColumns().length);
        assertEquals("ANNOCLS", cls.getDiscriminator().getColumns()[0].
View Full Code Here

       
        JDBCConfiguration conf =
            (JDBCConfiguration) ((OpenJPAEntityManagerFactorySPI) pm)
            .getConfiguration();
        DBDictionary dict = conf.getDBDictionaryInstance();
        MappingRepository repos = conf.getMappingRepositoryInstance();
        ClassMapping mapping = repos.getMapping(RuntimeTest1.class,
                pm.getClassLoader(), true);
       
        _tableName = mapping.getTable().getName();
        _fullTableName = dict.getFullName(mapping.getTable(), false);
        _pkColName = mapping.getTable().getPrimaryKey().
View Full Code Here

       
        JDBCConfiguration conf =
            (JDBCConfiguration) ((OpenJPAEntityManagerFactorySPI) pm)
            .getConfiguration();
        DBDictionary dict = conf.getDBDictionaryInstance();
        MappingRepository repos = conf.getMappingRepositoryInstance();
       
        ClassMapping mappingA = repos.getMapping(AttachD.class,
                pm.getClassLoader(), true);
        String tableNameA = mappingA.getTable().getName();
        String fullTableNameA = dict.getFullName(mappingA.getTable(), false);
        String relColNameA = mappingA.getFieldMapping("a").
                getColumns()[0].getName();
       
        ClassMapping mappingD = repos.getMapping(AttachA.class,
                pm.getClassLoader(), true);
        String tableNameD = mappingD.getTable().getName();
        String fullTableNameD = dict.getFullName(mappingD.getTable(), false);
        String pkColNameD = mappingD.getTable().getPrimaryKey().
                getColumns()[0].getName();
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.meta.MappingRepository

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.