Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.Id


    public Class getDataStoreIdType(ClassMetaData meta) {
        return Id.class;
    }

    public Object copyDataStoreId(Object oid, ClassMetaData meta) {
        Id id = (Id) oid;
        return new Id(meta.getDescribedType(), id.getId(),
            id.hasSubclasses());
    }
View Full Code Here


        OpenJPAEntityManager pm = getPM();
        RuntimeTest1 b = (RuntimeTest1) pm.find(RuntimeTest1.class, _id);
        assertEquals("STRING", b.getStringField());

        // invalid with possible subclasses should throw immediate exception
        Object invalidId = new Id(RuntimeTest1.class, -1L);
        try {
            pm.find(RuntimeTest1.class, invalidId);
            fail("Invalid Object");
        } catch (Exception e) {
        }

        // invalid without subclasses and without validating should return
        // hollow
        invalidId = new Id(RuntimeTest4.class, -1L);
        try {
            RuntimeTest4 a = (RuntimeTest4) pm.getReference(RuntimeTest4.class,
                invalidId);
            assertNotNull("invalid without subclasses and without validating "
                + "should return hollow or throw exception", a);
            a.getName();
            fail("Allowed access of invalid hollow instance.");
        }
        catch (EntityNotFoundException enfe) {
            // expected
        }

        invalidId = new Id(RuntimeTest4.class, -3L);
        assertNull(pm.find(RuntimeTest4.class, invalidId));

        endEm(pm);
    }
View Full Code Here

        iter = pcs.iterator();
        assertTrue(iter.next() == iter.next());
        endEm(pm);

        // invalid id causes exception
        Object invalidId = new Id(RuntimeTest4.class, -1L);
        pm = getPM();
        idlist = new ArrayList();
        idlist.add(_id);
        idlist.add(invalidId);
        try {
View Full Code Here

    public Class<?> getDataStoreIdType(ClassMetaData meta) {
        return Id.class;
    }

    public Object copyDataStoreId(Object oid, ClassMetaData meta) {
        Id id = (Id) oid;
        return new Id(meta.getDescribedType(), id.getId(), id.hasSubclasses());
    }
View Full Code Here

    public Object newDataStoreId(Object val, ClassMetaData meta) {
        return Id.newInstance(meta.getDescribedType(), val);
    }

    public Id newDataStoreId(long id, ClassMapping mapping, boolean subs) {
        return new Id(mapping.getDescribedType(), id, subs);
    }
View Full Code Here

        assertEquals(sql.toString(), 1, sql.size());
        assertNotSQL(_outer);
        sql.clear();
       
        // should outer join with non-exact id
        Id oid = new Id(JoinSubclassBase.class, ((Id) _base).getId());
        pm = (OpenJPAEntityManager)currentEntityManager();
        pc = (JoinSubclassBase) pm.getObjectId(oid);
        assertEquals(1, pc.getBaseField());
        pm.close();
       
View Full Code Here

        assertEquals(sql.toString(), 1, sql.size());
        assertNotSQL(_outer);
        sql.clear();
       
        // should outer join with non-exact id
        Id oid = new Id(JoinSubclassBase.class, ((Id) _baseSubFlat).getId());
        pm = (OpenJPAEntityManager)currentEntityManager();
        pc = (JoinSubclassBaseSubFlat) pm.getObjectId(oid);
        assertEquals(3, pc.getBaseField());
        assertEquals(4, pc.getBaseSubVertField());
        assertEquals(5, pc.getBaseSubFlatField());
View Full Code Here

        assertEquals(1, sql.size());
        assertNotSQL(_outer);
        sql.clear();
       
        // should outer join with non-exact oid
        oid = new Id(Base.class, ((Id) oid).getId());
        pm = (OpenJPAEntityManager)currentEntityManager();
        pc = (Base) pm.getObjectId(oid);
        assertEquals(1, pc.getBaseField());
        assertEquals(Base.class, pc.getClass());
        pm.close();
View Full Code Here

        Base pc = new Base();
        pc.setBaseField(1);
        Object oid = persist(pc);
        sql.clear();
       
        Id id = new Id(Base.class, -1);
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        try {
            pm.getObjectId(id);
            fail("No exception on bad id.");
        } catch (Exception jonfe) {
View Full Code Here

        assertEquals(1, sql.size());
        assertNotSQL(_outer);
        sql.clear();
       
        // should outer join with inexact oid
        oid = new Id(Base.class, ((Id) oid).getId());
        pm = (OpenJPAEntityManager)currentEntityManager();
        pc = (BaseSub1Sub2) pm.getObjectId(oid);
        assertEquals(4, pc.getBaseField());
        assertEquals(5, pc.getBaseSub1Field());
        assertEquals(6, pc.getBaseSub1Sub2Field());
View Full Code Here

TOP

Related Classes of org.apache.openjpa.util.Id

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.