Package org.apache.openjpa.jdbc.meta

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


     */
    public void testSQLKeywords() {
        OpenJPAEntityManagerFactorySPI emf =
            (OpenJPAEntityManagerFactorySPI) Persistence
                    .createEntityManagerFactory("test");
        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());
        closeEMF(emf);
    }
View Full Code Here


     * Parses the given annotation to create and cache a
     * {@link SQLResultSetMappingMetaData}.
     */
    private void parseSQLResultSetMappings(ClassMapping cm,
        SqlResultSetMapping... annos) {
        MappingRepository repos = (MappingRepository) getRepository();
        Log log = getLog();
        for (SqlResultSetMapping anno : annos) {
            if (log.isTraceEnabled())
                log.trace(_loc.get("parse-sqlrsmapping", anno.name()));

            QueryResultMapping result = repos.getCachedQueryResultMapping
                (null, anno.name());
            if (result != null) {
                if (log.isWarnEnabled())
                    log.warn(_loc.get("dup-sqlrsmapping", anno.name(), cm));
                continue;
            }

            result = repos.addQueryResultMapping(null, anno.name());
            result.setSource(getSourceFile(), cm.getDescribedType(),
                result.SRC_ANNOTATIONS);

            for (EntityResult entity : anno.entities()) {
                QueryResultMapping.PCResult entityResult = result.addPCResult
View Full Code Here

        JDBCConfiguration conf) {
        String action = conf.getSynchronizeMappings();
        if (StringUtils.isEmpty(action))
            return;

        MappingRepository repo = conf.getMappingRepositoryInstance();
        Collection<Class<?>> classes = repo.loadPersistentTypes(false, loader);
        if (classes.isEmpty())
            return;

        String props = Configurations.getProperties(action);
        action = Configurations.getClassName(action);
View Full Code Here

        String name = attrs.getValue("name");
        Log log = getLog();
        if (log.isTraceEnabled())
            log.trace(_loc.get("parse-sqlrsmapping", name));

        MappingRepository repos = (MappingRepository) getRepository();
        QueryResultMapping result = repos.getCachedQueryResultMapping
            (null, name);
        if (result != null && log.isWarnEnabled())
            log.warn(_loc.get("override-sqlrsmapping", name,
                currentLocation()));

        result = repos.addQueryResultMapping(null, name);
        result.setListingIndex(_resultIdx++);
        addComments(result);

        Object cur = currentElement();
        Object scope = (cur instanceof ClassMetaData)
View Full Code Here

     */
    private void setPersistenceCapableParameter(Map<Integer,Object> result,
        Object pc, Integer[] 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

     * 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

            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

       
        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

//        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

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.