Package org.hibernate.cfg.reveng

Examples of org.hibernate.cfg.reveng.TableIdentifier


 
  public void testMetaAttributes() {
   
    ReverseEngineeringStrategy res = buildOverrideRepository().addResource(OVERRIDETEST_REVENG_XML).getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy());
   
    TableIdentifier tableIdentifier = new TableIdentifier(null, null, "TblTest");
    Map attributes = res.tableToMetaAttributes(tableIdentifier);
    assertNotNull(attributes);
    assertEquals(attributes.size(),1);
    MetaAttribute ma = (MetaAttribute) attributes.get("use-in-test");
    assertEquals(ma.getName(), "use-in-test");
    assertEquals(ma.getValue(), "true");
       
    tableIdentifier = new TableIdentifier(settings.getDefaultCatalogName(), "Werd", "Testy");
    attributes = res.tableToMetaAttributes( tableIdentifier );
    assertNotNull(attributes);
    ma = (MetaAttribute) attributes.get( "werd-meta" );
    assertEquals(ma.getName(), "werd-meta");
    assertEquals(ma.getValues().size(), 2);       
 
    tableIdentifier = new TableIdentifier(null, "Werd", "MetaTable");
    attributes = res.tableToMetaAttributes( tableIdentifier );
    assertNotNull(attributes);
    assertEquals(2, attributes.size());
    ma = (MetaAttribute) attributes.get("specific-werd");
    assertEquals(ma.getName(), "specific-werd");
    assertEquals(ma.getValue(), "a one");
   
    ma = (MetaAttribute) attributes.get( "werd-meta" );
    assertEquals(ma.getName(), "werd-meta");
    assertEquals(1, ma.getValues().size()); // as long as no inherit this should be one
    assertEquals("value three", ma.getValue());
 
    tableIdentifier = new TableIdentifier(null, null, "Nothing");
    assertEquals(null, res.tableToMetaAttributes(tableIdentifier));
   
    assertNull(res.columnToMetaAttributes(new TableIdentifier("Nothing"), "bogus"));
    assertNull(res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "bogusColumn" ));
    attributes = res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "MetaColumn" );
    assertEquals(1, attributes.size());
    ma = (MetaAttribute) attributes.get("specific-column");
    assertEquals("specific-column",ma.getName());
    assertEquals("yes a column with meta",ma.getValue());
   
View Full Code Here


        continue;
      }

       
      RootClass rc = new RootClass();
      TableIdentifier tableIdentifier = TableIdentifier.create(table);
      String className = revengStrategy.tableToClassName( tableIdentifier );
      log.debug("Building entity " + className + " based on " + tableIdentifier);
      rc.setEntityName( className );
      rc.setClassName( className );
      rc.setProxyInterfaceName( rc.getEntityName() ); // TODO: configurable ?
View Full Code Here

  private String bindCollection(PersistentClass rc, ForeignKey fromForeignKey, ForeignKey toForeignKey, Collection collection) {
    ForeignKey targetKey = fromForeignKey;
    String collectionRole = null;
    boolean collectionLazy = false;
    boolean collectionInverse = false;
    TableIdentifier foreignKeyTable = null;
    String tableToClassName;

    if(toForeignKey!=null) {
      targetKey = toForeignKey;
    }

    boolean uniqueReference = isUniqueReference(targetKey); // TODO: need to look one step further for many-to-many!
    foreignKeyTable = TableIdentifier.create( targetKey.getTable() );
    TableIdentifier foreignKeyReferencedTable = TableIdentifier.create( targetKey.getReferencedTable() );

    if(toForeignKey==null) {

      collectionRole = revengStrategy.foreignKeyToCollectionName(
          fromForeignKey.getName(),
View Full Code Here

        Column col = (Column) iter.next();
        keyColumns.add(col);
      }
    }

    final TableIdentifier tableIdentifier = TableIdentifier.create(table);

    String tableIdentifierStrategyName = "assigned";

    boolean naturalId;

    if (keyColumns.size()>1) {
      log.debug("id strategy for " + rc.getEntityName() + " since it has a multiple column primary key");
      naturalId = true;

      id = handleCompositeKey(rc, processed, keyColumns, mapping);
      idPropertyname = revengStrategy.tableToIdentifierPropertyName(tableIdentifier);
      if(idPropertyname==null) {
        idPropertyname = "id";
      }
    }
    else {
      pki.suggestedStrategy = revengStrategy.getTableIdentifierStrategyName(tableIdentifier);
      String suggestedStrategy = pki.suggestedStrategy;
      if(suggestedStrategy==null) {
        suggestedStrategy = collector.getSuggestedIdentifierStrategy( tableIdentifier.getCatalog(), tableIdentifier.getSchema(), tableIdentifier.getName() );
        if(suggestedStrategy==null) {
          suggestedStrategy = "assigned";
        }
        tableIdentifierStrategyName = suggestedStrategy;
      } else {
View Full Code Here

      }
    }
  }

  private void bindColumnsToVersioning(Table table, RootClass rc, Set processed, Mapping mapping) {
    TableIdentifier identifier = TableIdentifier.create(table);

    String optimisticLockColumnName = revengStrategy.getOptimisticLockColumnName(identifier);

    if(optimisticLockColumnName!=null) {
      Column column = table.getColumn(new Column(optimisticLockColumnName));
View Full Code Here

        continue;
      }

       
      RootClass rc = new RootClass();
      TableIdentifier tableIdentifier = TableIdentifier.create(table);
      String className = revengStrategy.tableToClassName( tableIdentifier );
      log.debug("Building entity " + className + " based on " + tableIdentifier);
      rc.setEntityName( className );
      rc.setJpaEntityName( StringHelper.unqualify( className ) );
      rc.setClassName( className );
View Full Code Here

  private String bindCollection(PersistentClass rc, ForeignKey fromForeignKey, ForeignKey toForeignKey, Collection collection) {
    ForeignKey targetKey = fromForeignKey;
    String collectionRole = null;
    boolean collectionLazy = false;
    boolean collectionInverse = false;
    TableIdentifier foreignKeyTable = null;
    String tableToClassName;

    if(toForeignKey!=null) {
      targetKey = toForeignKey;
    }

    boolean uniqueReference = isUniqueReference(targetKey); // TODO: need to look one step further for many-to-many!
    foreignKeyTable = TableIdentifier.create( targetKey.getTable() );
    TableIdentifier foreignKeyReferencedTable = TableIdentifier.create( targetKey.getReferencedTable() );

    if(toForeignKey==null) {

      collectionRole = revengStrategy.foreignKeyToCollectionName(
          fromForeignKey.getName(),
View Full Code Here

        Column col = (Column) iter.next();
        keyColumns.add(col);
      }
    }

    final TableIdentifier tableIdentifier = TableIdentifier.create(table);

    String tableIdentifierStrategyName = "assigned";

    boolean naturalId;

    if (keyColumns.size()>1) {
      log.debug("id strategy for " + rc.getEntityName() + " since it has a multiple column primary key");
      naturalId = true;

      id = handleCompositeKey(rc, processed, keyColumns, mapping);
      idPropertyname = revengStrategy.tableToIdentifierPropertyName(tableIdentifier);
      if(idPropertyname==null) {
        idPropertyname = "id";
      }
    }
    else {
      pki.suggestedStrategy = revengStrategy.getTableIdentifierStrategyName(tableIdentifier);
      String suggestedStrategy = pki.suggestedStrategy;
      if(suggestedStrategy==null) {
        suggestedStrategy = collector.getSuggestedIdentifierStrategy( tableIdentifier.getCatalog(), tableIdentifier.getSchema(), tableIdentifier.getName() );
        if(suggestedStrategy==null) {
          suggestedStrategy = "assigned";
        }
        tableIdentifierStrategyName = suggestedStrategy;
      } else {
View Full Code Here

      }
    }
  }

  private void bindColumnsToVersioning(Table table, RootClass rc, Set processed, Mapping mapping) {
    TableIdentifier identifier = TableIdentifier.create(table);

    String optimisticLockColumnName = revengStrategy.getOptimisticLockColumnName(identifier);

    if(optimisticLockColumnName!=null) {
      Column column = table.getColumn(new Column(optimisticLockColumnName));
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.reveng.TableIdentifier

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.