org.hibernate.mapping.Join.getTable()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.hibernate.mapping.Join.getTable()方法的一些代码示例,展示了Join.getTable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Join.getTable()方法的具体详情如下:
包路径:org.hibernate.mapping.Join
类名称:Join
方法名:getTable

Join.getTable介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
 * @deprecated User {@link Component#Component(MetadataBuildingContext, Join)} instead.
 */
@Deprecated
public Component(MetadataImplementor metadata, Join join) throws MappingException {
  this( metadata, join.getTable(), join.getPersistentClass() );
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Needed for proper compliance with naming strategy, the property table
 * can be overriden if the properties are part of secondary tables
 */
private Map<String, Join> getJoinsPerRealTableName() {
  if ( joinsPerRealTableName == null ) {
    joinsPerRealTableName = new HashMap<String, Join>( joins.size() );
    for (Join join : joins.values()) {
      joinsPerRealTableName.put( join.getTable().getName(), join );
    }
  }
  return joinsPerRealTableName;
}

代码示例来源:origin: hibernate/hibernate-orm

public Component(MetadataBuildingContext metadata, Join join) throws MappingException {
  this( metadata, join.getTable(), join.getPersistentClass() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Table resolveTable(Identifier tableName) {
  if ( tableName == null ) {
    return primaryTable;
  }
  if ( Identifier.areEqual( primaryTableLogicalName, tableName ) ) {
    return primaryTable;
  }
  Join secondaryTableJoin = null;
  if ( secondaryTableJoinMap != null ) {
    //secondaryTableJoin = secondaryTableJoinMap.get( tableName );
    secondaryTableJoin = secondaryTableJoinMap.get( tableName.getCanonicalName() );
  }
  if ( secondaryTableJoin != null ) {
    return secondaryTableJoin.getTable();
  }
  if ( superEntityTableXref != null ) {
    return superEntityTableXref.resolveTable( tableName );
  }
  return null;
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Find appropriate table of the column.
 * It can come from a secondary table or from the main table of the persistent class
 *
 * @return appropriate table
 * @throws AnnotationException missing secondary table
 */
public Table getTable() {
  if ( table != null ){
    return table;
  }
  if ( isSecondary() ) {
    return getJoin().getTable();
  }
  else {
    return propertyHolder.getTable();
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private SecondaryTable findMatchingSecondaryTable(Join join) {
  final String nameToMatch = join.getTable().getQuotedName();
  SecondaryTable secondaryTable = annotatedClass.getAnnotation( SecondaryTable.class );
  if ( secondaryTable != null && nameToMatch.equals( secondaryTable.name() ) ) {
    return secondaryTable;
  }
  SecondaryTables secondaryTables = annotatedClass.getAnnotation( SecondaryTables.class );
  if ( secondaryTables != null ) {
    for ( SecondaryTable secondaryTablesEntry : secondaryTables.value() ) {
      if ( secondaryTablesEntry != null && nameToMatch.equals( secondaryTablesEntry.name() ) ) {
        return secondaryTablesEntry;
      }
    }
  }
  return null;
}

代码示例来源:origin: hibernate/hibernate-orm

private org.hibernate.annotations.Table findMatchingComplimentTableAnnotation(Join join) {
  String tableName = join.getTable().getQuotedName();
  org.hibernate.annotations.Table table = annotatedClass.getAnnotation( org.hibernate.annotations.Table.class );
  org.hibernate.annotations.Table matchingTable = null;
  if ( table != null && tableName.equals( table.appliesTo() ) ) {
    matchingTable = table;
  }
  else {
    Tables tables = annotatedClass.getAnnotation( Tables.class );
    if ( tables != null ) {
      for (org.hibernate.annotations.Table current : tables.value()) {
        if ( tableName.equals( current.appliesTo() ) ) {
          matchingTable = current;
          break;
        }
      }
    }
  }
  return matchingTable;
}

代码示例来源:origin: hibernate/hibernate-orm

if ( join.getTable().getQuotedName().equals( appliedTable ) ) {
  hibTable = join.getTable();
  break;

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings({"unchecked"})
  @Test
  public void testTableNames() {
    assert "sec_embid_versions".equals(
        ((Iterator<Join>)
            metadata().getEntityBinding(
                "org.hibernate.envers.test.integration.secondary.ids.SecondaryEmbIdTestEntity_AUD"
            ).getJoinIterator()).next().getTable().getName()
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings({"unchecked"})
  @Test
  public void testTableNames() {
    assert "secondary_AUD".equals(
        ((Iterator<Join>)
            metadata().getEntityBinding(
                "org.hibernate.envers.test.integration.secondary.SecondaryTestEntity_AUD"
            )
                .getJoinIterator())
            .next().getTable().getName()
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings({"unchecked"})
  @Test
  public void testTableNames() {
    assert "sec_mulid_versions".equals(
        ((Iterator<Join>)
            metadata().getEntityBinding(
                "org.hibernate.envers.test.integration.secondary.ids.SecondaryMulIdTestEntity_AUD"
            )
                .getJoinIterator())
            .next().getTable().getName()
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings({"unchecked"})
  @Test
  public void testTableNames() {
    assert "sec_versions".equals(
        ((Iterator<Join>)
            metadata().getEntityBinding(
                "org.hibernate.envers.test.integration.secondary.SecondaryNamingTestEntity_AUD"
            )
                .getJoinIterator())
            .next().getTable().getName()
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

final String originalTableName = join.getTable().getName();
String auditTableName = auditingData.getSecondaryTableDictionary().get( originalTableName );
if ( auditTableName == null ) {
final String schema = getSchema( auditingData.getAuditTable().schema(), join.getTable() );
final String catalog = getCatalog( auditingData.getAuditTable().catalog(), join.getTable() );

代码示例来源:origin: hibernate/hibernate-orm

while ( !found && joins.hasNext() ) {
  result = joins.next();
  currentTable = ( (Join) result ).getTable();
  try {
    context.getMetadataCollector().getPhysicalColumnName( currentTable, columnName );

代码示例来源:origin: hibernate/hibernate-orm

private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, MetadataBuildingContext buildingContext) {
  SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
  join.setKey( key );
  setFKNameIfDefined( join );
  key.setCascadeDeleteEnabled( false );
  TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, buildingContext );
  join.createPrimaryKey();
  join.createForeignKey();
  persistentClass.addJoin( join );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testDefaultValue() throws Exception {
  Join join = (Join) metadata().getEntityBinding( Life.class.getName() ).getJoinClosureIterator().next();
  assertEquals( "ExtendedLife", join.getTable().getName() );
  org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
  owner.setName( "LIFE_ID" );
  assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) );
  Session s = openSession();
  Transaction tx = s.beginTransaction();
  Life life = new Life();
  life.duration = 15;
  life.fullDescription = "Long long description";
  s.persist( life );
  tx.commit();
  s.close();
  s = openSession();
  tx = s.beginTransaction();
  Query q = s.createQuery( "from " + Life.class.getName() );
  life = (Life) q.uniqueResult();
  assertEquals( "Long long description", life.fullDescription );
  tx.commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testSecondaryTableIndex(){
  PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
  Join join = (Join)entity.getJoinIterator().next();
  Iterator<Index> itr = join.getTable().getIndexIterator();
  assertTrue( itr.hasNext() );
  Index index = itr.next();
  assertFalse( itr.hasNext() );
  assertTrue( "index name is not generated", StringHelper.isNotEmpty( index.getName() ) );
  assertEquals( 2, index.getColumnSpan() );
  Iterator<Column> columnIterator = index.getColumnIterator();
  Column column = columnIterator.next();
  assertEquals( "dealer_name", column.getName() );
  column = columnIterator.next();
  assertEquals( "rate", column.getName() );
  assertSame( join.getTable(), index.getTable() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testCompositePK() throws Exception {
  Join join = (Join) metadata().getEntityBinding( Dog.class.getName() ).getJoinClosureIterator().next();
  assertEquals( "DogThoroughbred", join.getTable().getName() );
  org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
  owner.setName( "OWNER_NAME" );
  assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) );
  Session s = openSession();
  Transaction tx = s.beginTransaction();
  Dog dog = new Dog();
  DogPk id = new DogPk();
  id.name = "Thalie";
  id.ownerName = "Martine";
  dog.id = id;
  dog.weight = 30;
  dog.thoroughbredName = "Colley";
  s.persist( dog );
  tx.commit();
  s.close();
  s = openSession();
  tx = s.beginTransaction();
  Query q = s.createQuery( "from Dog" );
  dog = (Dog) q.uniqueResult();
  assertEquals( "Colley", dog.thoroughbredName );
  tx.commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void associateSubclassNamesToSubclassTableIndexes(
    PersistentClass persistentClass,
    Set<String> classNames,
    String[][] mapping,
    SessionFactoryImplementor factory) {
  final String tableName = persistentClass.getTable().getQualifiedName(
      factory.getDialect(),
      factory.getSettings().getDefaultCatalogName(),
      factory.getSettings().getDefaultSchemaName()
  );
  associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );
  Iterator itr = persistentClass.getJoinIterator();
  while ( itr.hasNext() ) {
    final Join join = (Join) itr.next();
    final String secondaryTableName = join.getTable().getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
    );
    associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

join.setTable( originalJoin.getTable() );
join.setInverse( true );
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );

相关文章