Examples of RootClass


Examples of org.hibernate.mapping.RootClass

            "Unable to define/override @Version on a subclass: "
                + propertyHolder.getEntityName()
        );
      }
      log.debug( inferredData.getPropertyName() + " is a version property" );
      RootClass rootClass = (RootClass) propertyHolder.getPersistentClass();
      boolean lazy = false;
      PropertyBinder propBinder = new PropertyBinder();
      propBinder.setName( inferredData.getPropertyName() );
      propBinder.setReturnedClassName( inferredData.getTypeName() );
      propBinder.setLazy( lazy );
      propBinder.setPropertyAccessorName( inferredData.getDefaultAccess() );
      propBinder.setColumns( columns );
      propBinder.setHolder( propertyHolder ); //PropertyHolderBuilder.buildPropertyHolder(rootClass)
      propBinder.setProperty( property );
      propBinder.setReturnedClass( inferredData.getPropertyClass() );

      propBinder.setMappings( mappings );
      Property prop = propBinder.bind();
      rootClass.setVersion( prop );
      SimpleValue simpleValue = (SimpleValue) prop.getValue();
      if ( !simpleValue.isTypeSpecified() ) simpleValue.setTypeName( "integer" );
      simpleValue.setNullValue( "undefined" );
      rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
      log.debug(
          "Version name: " + rootClass.getVersion().getName() + ", unsavedValue: " + ( (SimpleValue) rootClass
              .getVersion()
              .getValue() ).getNullValue()
      );
    }
    else if ( property.isAnnotationPresent( ManyToOne.class ) ) {
View Full Code Here

Examples of org.objectweb.speedo.pobjects.inheritance.filtered.datastorelid.RootClass

  public void testA() {
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    ArrayList rcs = new ArrayList();
    rcs.add(new RootClass("rf1"));
    rcs.add(new RootClass("rf2"));
    rcs.add(new Subclass1("rf3", "f1_3"));
    rcs.add(new Subclass12("rf4", "f1_4", "f12_4"));
    rcs.add(new Subclass2("rf5", "f2_5"));
    pm.makePersistentAll(rcs);
    pm.currentTransaction().commit();

    pm.currentTransaction().begin();
    checkNumberOfInstanceWithExtent(RootClass.class, false, 2, pm);
    checkNumberOfInstanceWithExtent(RootClass.class, true, 5, pm);

    checkNumberOfInstanceWithExtent(Subclass1.class, false, 1, pm);
    checkNumberOfInstanceWithExtent(Subclass1.class, true, 2, pm);

    checkNumberOfInstanceWithExtent(Subclass12.class, true, 1, pm);
    checkNumberOfInstanceWithExtent(Subclass12.class, false, 1, pm);

    checkNumberOfInstanceWithExtent(Subclass2.class, false, 1, pm);
    checkNumberOfInstanceWithExtent(Subclass2.class, true, 1, pm);
    pm.currentTransaction().commit();

    pm.currentTransaction().begin();
    for(int i=0; i<rcs.size(); i++) {
      rcs.set(i, pm.getObjectId(rcs.get(i)));
    }
    pm.currentTransaction().commit();
    pm.evictAll();

    pm.currentTransaction().begin();
    for(int i=0; i<rcs.size(); i++) {
      pm.getObjectById(rcs.get(i), false);
    }
    pm.currentTransaction().commit();

    pm.evictAll();

    pm.currentTransaction().begin();
    Query query = pm.newQuery(RootClass.class);
    Collection col = (Collection) query.execute();
    Iterator it = col.iterator();
    int size = 0;
    while(it.hasNext()) {
      RootClass rc = (RootClass) it.next();
      size ++;
      logger.log(BasicLevel.DEBUG, "rc.rootField=" + rc.getRootField());
      if ("rf1".equals(rc.getRootField())) {
      } else if ("rf2".equals(rc.getRootField())) {
      } else if ("rf3".equals(rc.getRootField())) {
        assertTrue("Bad class instance" + rc.getClass().getName(), rc instanceof Subclass1);
        assertEquals("Bad f1 value", "f1_3", ((Subclass1) rc).getF1());
      } else if ("rf4".equals(rc.getRootField())) {
        assertTrue("Bad class instance" + rc.getClass().getName(), rc instanceof Subclass12);
        assertEquals("Bad f1 value", "f1_4", ((Subclass12) rc).getF1());
        assertEquals("Bad f1 value", "f12_4", ((Subclass12) rc).getF12());
      } else if ("rf5".equals(rc.getRootField())) {
        assertTrue("Bad class instance" + rc.getClass().getName(), rc instanceof Subclass2);
        assertEquals("Bad f1 value", "f2_5", ((Subclass2) rc).getF2());
      } else {
        fail("Unmanaged rootField value: " + rc.getRootField());
      }
    }
    query.closeAll();
    assertEquals("bad query result size", 5, size);
    pm.currentTransaction().commit();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.