Package org.apache.ojb.broker.metadata

Examples of org.apache.ojb.broker.metadata.ClassDescriptor


                broker.store(tmpArticle);
                broker.commitTransaction();
                broker.clearCache();

                // switch to shallow retrieval
                ClassDescriptor cld = broker.getClassDescriptor(Article.class);
                ObjectReferenceDescriptor ord =
                        (ObjectReferenceDescriptor) cld.getObjectReferenceDescriptors().get(0);
                ord.setCascadeRetrieve(false);
                // should work without setting cld
                // broker.setClassDescriptor(cld);

                Article article = (Article) broker.getObjectByIdentity(tmpOID);
View Full Code Here


        broker.store(tmpArticle);
        broker.commitTransaction();
        broker.clearCache();

        // switch to shallow retrieval
        ClassDescriptor cld = broker.getClassDescriptor(Article.class);
        // article only has one ord
        ObjectReferenceDescriptor ord =
                (ObjectReferenceDescriptor) cld.getObjectReferenceDescriptors().get(0);
        ord.setCascadeRetrieve(false);
        // should work without setting cld
        // broker.setClassDescriptor(cld);

        Article article = (Article) broker.getObjectByIdentity(tmpOID);
View Full Code Here

        broker.store(tmpArticle);
        broker.commitTransaction();
        broker.clearCache();

        // switch to shallow retrieval
        ClassDescriptor cld = broker.getClassDescriptor(Article.class);
        ObjectReferenceDescriptor ord =
                (ObjectReferenceDescriptor) cld.getObjectReferenceDescriptors().get(0);
        ord.setCascadeRetrieve(false);
        // should work without setting cld
        // broker.setClassDescriptor(cld);

        Article article = (Article) broker.getObjectByIdentity(tmpOID);
View Full Code Here

   * prefetch Articles for ProductGroupsWithArray, Does not yet work with
   * Arrays
   */
    public void testPrefetchedArraySingleKey()
    {
        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
        Class articleProxy = cldArticle.getProxyClass();

        //
        // use ProductGroup and Articles with disabled Proxy
        //
        broker.clearCache();
        cldArticle.setProxyClass(null);

        Criteria crit = new Criteria();
        crit.addLessOrEqualThan("groupId", new Integer(5));
        QueryByCriteria q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
        q.addOrderByDescending("groupId");
        q.addPrefetchedRelationship("allArticlesInGroup");

        Collection results = broker.getCollectionByQuery(q);
        assertNotNull(results);
        assertTrue(results.size() > 0);
        ProductGroupWithArray pg = (ProductGroupWithArray) results.toArray()[0];
        int articleSize = pg.getAllArticles().length;
        assertTrue(articleSize != 0 );
        String articleString = Arrays.asList(pg.getAllArticles()).toString();

        //
        // use ProductGroupWithArray and Articles with original Proxy settings
        //
        broker.clearCache();
        cldArticle.setProxyClass(articleProxy);


        crit = new Criteria();
        crit.addEqualTo("groupId", new Integer(5));
        q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
View Full Code Here

    /**
   * prefetch Articles for ProductGroups
   */
    public void testPrefetchedCollectionSingleKey()
    {
        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
        Class productGroupProxy = cldProductGroup.getProxyClass();
        Class articleProxy = cldArticle.getProxyClass();

        //
        // use ProductGroup and Articles with disabled Proxy
        //
        broker.clearCache();
        cldProductGroup.setProxyClass(null);
        cldProductGroup.setProxyClassName(null);
        cldArticle.setProxyClass(null);
        cldArticle.setProxyClassName(null);
        broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
        broker.getDescriptorRepository().setClassDescriptor(cldArticle);

        Criteria crit = new Criteria();
        crit.addLessOrEqualThan("groupId", new Integer(5));
        QueryByCriteria q = QueryFactory.newQuery(ProductGroup.class, crit);
        q.addOrderByDescending("groupId");
        q.addPrefetchedRelationship("allArticlesInGroup");

        Collection results = broker.getCollectionByQuery(q);
        assertNotNull(results);
        assertTrue(results.size() > 0);
        InterfaceProductGroup pg = (InterfaceProductGroup) results.toArray()[0];
        assertNotNull(pg.getAllArticles());
        int articleSize = pg.getAllArticles().size();
        String articleString = pg.getAllArticles().toString();

        //
        // use ProductGroup and Articles with original Proxy settings
        //
        broker.clearCache();
        cldProductGroup.setProxyClass(productGroupProxy);
        cldProductGroup.setProxyClassName(productGroupProxy.getName());
        cldArticle.setProxyClass(articleProxy);
        cldArticle.setProxyClassName(articleProxy.getName());
        broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
        broker.getDescriptorRepository().setClassDescriptor(cldArticle);

        crit = new Criteria();
        crit.addEqualTo("groupId", new Integer(5));
View Full Code Here

    /**
   * prefetch ProductGroups for Articles
   */
    public void testPrefetchedReferencesSingleKey()
    {
        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
        Class productGroupProxy = cldProductGroup.getProxyClass();
        Class articleProxy = cldArticle.getProxyClass();

        //
        // use ProductGroup and Articles with disabled Proxy
        //
        broker.clearCache();
        cldProductGroup.setProxyClass(null);
        cldProductGroup.setProxyClassName(null);
        cldArticle.setProxyClass(null);
        cldArticle.setProxyClassName(null);
        broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
        broker.getDescriptorRepository().setClassDescriptor(cldArticle);

        Criteria crit = new Criteria();
        crit.addNotNull("productGroupId");
        crit.addLessOrEqualThan("productGroupId", new Integer(5));
        QueryByCriteria q = QueryFactory.newQuery(Article.class, crit);
        q.addOrderByDescending("productGroupId");
        q.addPrefetchedRelationship("productGroup");

        Collection results = broker.getCollectionByQuery(q);
        Set pgs = new HashSet();
        Iterator iter = results.iterator();
        while (iter.hasNext())
        {
            InterfaceArticle a = (InterfaceArticle) iter.next();
            pgs.add(a.getProductGroup().getName());
        }

        assertTrue(pgs.size() > 0);
        String pgsString = pgs.toString();

        //
        // use ProductGroup and Articles with original Proxy settings
        //
        broker.clearCache();
        cldProductGroup.setProxyClass(productGroupProxy);
        cldProductGroup.setProxyClassName(productGroupProxy.getName());
        cldArticle.setProxyClass(articleProxy);
        cldArticle.setProxyClassName(articleProxy.getName());
        broker.getDescriptorRepository().setClassDescriptor(cldProductGroup);
        broker.getDescriptorRepository().setClassDescriptor(cldArticle);

        crit = new Criteria();
        crit.addNotNull("productGroupId");
View Full Code Here

        assertNull("" + uid + " should be unique", result);

        //System.out.println("next free UID for InterfaceArticle : " + uid);

        // the next id from the sequence should be uid + 1, even if we did not store any object using uid.
      ClassDescriptor cld = broker.getClassDescriptor(InterfaceArticle.class);
        FieldDescriptor fld = cld.getFieldDescriptorByName("articleId");

        int nextUid = 1; //broker.serviceSequenceManager().getUniqueId(fld);
        assertEquals("nextUid - uid = 1 !!!", 1, nextUid - uid);

  }
View Full Code Here

     * changes, nothing should happen.
     */
    public void testNull_0_Complex() throws Exception
    {
        Class objClass = ObjectRepository.E.class;
        ClassDescriptor cld = broker.getClassDescriptor(objClass);
        Integer someOtherValue = new Integer(1111111111);
        String insert = "INSERT INTO TABLE_E VALUES(0,"+someOtherValue.intValue()+")";
        String delete = "DELETE FROM TABLE_E WHERE ID=0";
        Statement stmt;
        try
View Full Code Here

     * new object with PK 0, because PK field is not primitive
     */
    public void testNull_0_Complex_2() throws Exception
    {
        Class objClass = ObjectRepository.E.class;
        ClassDescriptor cld = broker.getClassDescriptor(objClass);
        Integer someOtherValue = new Integer(1111111111);
        String delete = "DELETE FROM TABLE_E WHERE ID=0";
        Statement stmt;
        try
        {
View Full Code Here

    /**
     * performs a test to check if metadata can be read
     */
    public void testGetDescriptor() throws Exception
    {
        ClassDescriptor cld = broker.getClassDescriptor(Article.class);
        assertNotNull("classdescriptor should not be null", cld);
    }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.metadata.ClassDescriptor

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.