javax.persistence.JoinColumn.name()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(143)

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

JoinColumn.name介绍

暂无

代码示例

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

public String next() {
  return joinColumns[counter++].name();
}

代码示例来源:origin: requery/requery

JoinTableAssociation(JoinTable table) {
  this.table = table;
  this.columns = new LinkedHashSet<>();
  for (JoinColumn column : table.joinColumns()) {
    String columnName = column.name();
    ForeignKey foreignKey = column.foreignKey();
    ReferentialAction action = mapConstraint(foreignKey.value());
    columns.add(new AssociativeReference(columnName, null, null, action, action));
  }
  for (JoinColumn column : table.inverseJoinColumns()) {
    String columnName = column.name();
    ForeignKey foreignKey = column.foreignKey();
    ReferentialAction action = mapConstraint(foreignKey.value());
    columns.add(new AssociativeReference(columnName, null, null, action, action));
  }
}

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

colName = joinAnn.name();
columnDefinition = joinAnn.columnDefinition();
referencedColumnName = joinAnn.referencedColumnName();

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

JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
if ( (prop.isAnnotationPresent( JoinColumn.class )
    && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
  isRequiredAnnotationPresent = true;
    if ( columnName.equals( columnAnnotation.name() ) ) {
      isRequiredAnnotationPresent = true;
      break;

代码示例来源:origin: Impetus/Kundera

/**
 * Gets the relation field name.
 * 
 * @param relation
 *            the relation
 * @return the relation field name
 */
private String getJoinColumnName(Field relation)
{
  String columnName = null;
  JoinColumn ann = relation.getAnnotation(JoinColumn.class);
  if (ann != null)
  {
    columnName = ann.name();
  }
  return StringUtils.isBlank(columnName) ? relation.getName() : columnName;
}

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

setSqlType( getBuildingContext().getObjectNameNormalizer().applyGlobalQuoting( annJoin.columnDefinition() ) );
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.name() ) ) {
  setLogicalColumnName( annJoin.name() );

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

/**
 * When there's a single join column, we still wrap it with a JoinColumns
 * annotation.
 */
@Test
public void testSingleJoinColumn() throws Exception {
  reader = getReader( Entity1.class, "field1", "many-to-one.orm2.xml" );
  assertAnnotationPresent( ManyToOne.class );
  assertAnnotationNotPresent( JoinColumn.class );
  assertAnnotationPresent( JoinColumns.class );
  assertAnnotationNotPresent( JoinTable.class );
  JoinColumns joinColumnsAnno = reader.getAnnotation( JoinColumns.class );
  JoinColumn[] joinColumns = joinColumnsAnno.value();
  assertEquals( 1, joinColumns.length );
  assertEquals( "col1", joinColumns[0].name() );
  assertEquals( "col2", joinColumns[0].referencedColumnName() );
  assertEquals( "table1", joinColumns[0].table() );
}

代码示例来源:origin: Impetus/Kundera

@Override
public void addRelationIntoMetadata(Field relationField, EntityMetadata metadata)
{
  // taking field's type as foreign entity, ignoring "targetEntity"
  Class<?> targetEntity = relationField.getType();
  ManyToOne ann = relationField.getAnnotation(ManyToOne.class);
  Relation relation = new Relation(relationField, targetEntity, null, ann.fetch(), Arrays.asList(ann.cascade()),
      ann.optional(), null, // mappedBy is null
      Relation.ForeignKey.MANY_TO_ONE);
  boolean isJoinedByFK = relationField.isAnnotationPresent(JoinColumn.class);
  if (relationField.isAnnotationPresent(AssociationOverride.class))
  {
    AssociationOverride annotation = relationField.getAnnotation(AssociationOverride.class);
    JoinColumn[] joinColumns = annotation.joinColumns();
    relation.setJoinColumnName(joinColumns[0].name());
  }
  else if (isJoinedByFK)
  {
    JoinColumn joinColumnAnn = relationField.getAnnotation(JoinColumn.class);
    relation.setJoinColumnName(StringUtils.isBlank(joinColumnAnn.name()) ? relationField.getName()
        : joinColumnAnn.name());
  }
  else
  {
    relation.setJoinColumnName(relationField.getName());
  }
  relation.setBiDirectionalField(metadata.getEntityClazz());
  metadata.addRelation(relationField.getName(), relation);
}

代码示例来源:origin: zstackio/zstack

String toSQL() {
    ZQLMetadata.InventoryMetadata metadata = ZQLMetadata.getInventoryMetadataByName(inventoryClass.getName());
    if (metadata == null) {
      throw new CloudRuntimeException(String.format("cannot find InventoryMetadata for class[%s]", inventoryClass));
    }
    Field primaryKey = EntityMetadata.getPrimaryKeyField(metadata.inventoryAnnotation.mappingVOClass());
    Class mappingInventoryClass = annotation.mappingClass();
    ZQLMetadata.InventoryMetadata mappingInventoryMetadata = ZQLMetadata.getInventoryMetadataByName(mappingInventoryClass.getName());
    String mappingEntityName = mappingInventoryClass.getSimpleName();
    return String.format("%s.%s IN (SELECT %s.%s FROM %s %s WHERE %s.%s %%s %%s)",
        inventoryClass.getSimpleName(), primaryKey.getName(), mappingEntityName,
        annotation.joinColumn().name(), mappingInventoryMetadata.inventoryAnnotation.mappingVOClass().getSimpleName(),
        mappingEntityName, mappingEntityName, annotation.joinColumn().referencedColumnName());
  }
}

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

/**
 * Add a JoinColumn
 * <p>
 * The order is generally true for OneToMany and false for ManyToOne relationships.
 * </p>
 */
public void addJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) {
 if (!"".equals(jc.table())) {
  setTable(jc.table());
 }
 if (!"".equals(jc.name()) || !"".equals(jc.referencedColumnName())) {
  // only add the join column details when name or referencedColumnName is specified
  addJoinColumn(new DeployTableJoinColumn(order, jc, beanTable));
 }
}

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

&& ! BinderHelper.isEmptyAnnotationValue( joinColumn.name() )
  && joinColumn.name().equals( columnName )
  && !property.isAnnotationPresent( MapsId.class ) ) {
hasSpecjManyToOne = true;

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

@Test
public void testMultipleJoinColumns() throws Exception {
  reader = getReader( Entity1.class, "field1", "many-to-one.orm3.xml" );
  assertAnnotationPresent( ManyToOne.class );
  assertAnnotationNotPresent( JoinColumn.class );
  assertAnnotationPresent( JoinColumns.class );
  assertAnnotationNotPresent( JoinTable.class );
  JoinColumns joinColumnsAnno = reader.getAnnotation( JoinColumns.class );
  JoinColumn[] joinColumns = joinColumnsAnno.value();
  assertEquals( 2, joinColumns.length );
  assertEquals( "", joinColumns[0].name() );
  assertEquals( "", joinColumns[0].referencedColumnName() );
  assertEquals( "", joinColumns[0].table() );
  assertEquals( "", joinColumns[0].columnDefinition() );
  assertTrue( joinColumns[0].insertable() );
  assertTrue( joinColumns[0].updatable() );
  assertTrue( joinColumns[0].nullable() );
  assertFalse( joinColumns[0].unique() );
  assertEquals( "col1", joinColumns[1].name() );
  assertEquals( "col2", joinColumns[1].referencedColumnName() );
  assertEquals( "table1", joinColumns[1].table() );
  assertEquals( "int", joinColumns[1].columnDefinition() );
  assertFalse( joinColumns[1].insertable() );
  assertFalse( joinColumns[1].updatable() );
  assertFalse( joinColumns[1].nullable() );
  assertTrue( joinColumns[1].unique() );
}

代码示例来源:origin: Impetus/Kundera

/**
 * Gets the join column name.
 * 
 * @return the joinColumnName
 */
public String getJoinColumnName(final KunderaMetadata kunderaMetadata)
{
      
  if(joinColumnName == null && isJoinedByPrimaryKey)
  {
    EntityMetadata joinClassMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, targetEntity);
    joinColumnName  = ((AbstractAttribute)joinClassMetadata.getIdAttribute()).getJPAColumnName();
  }
  
  if(joinTableMetadata != null)
  {
    joinColumnName = joinTableMetadata.getJoinColumns() != null? joinTableMetadata.getJoinColumns().iterator().next():null;
  }
  
  if(isBiDirectional())
  {
    // Give precedence to join column name!
    if(biDirectionalField.isAnnotationPresent(JoinColumn.class))
    {
      joinColumnName = biDirectionalField.getAnnotation(JoinColumn.class).name();
    }
  }
  
  return joinColumnName !=null? joinColumnName:property.getName();
}

代码示例来源:origin: Impetus/Kundera

/**
 * Instantiates a new join table metadata.
 * 
 * @param relationField
 *            the relation field
 */
public JoinTableMetadata(Field relationField)
{
  JoinTable jtAnn = relationField.getAnnotation(JoinTable.class);
  setJoinTableName(jtAnn.name());
  setJoinTableSchema(jtAnn.schema());
  for (JoinColumn joinColumn : jtAnn.joinColumns())
  {
    addJoinColumns(joinColumn.name());
  }
  for (JoinColumn inverseJoinColumn : jtAnn.inverseJoinColumns())
  {
    addInverseJoinColumns(inverseJoinColumn.name());
  }
}

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

public DeployTableJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) {
 this(jc.referencedColumnName(), jc.name(), jc.insertable(), jc.updatable());
 setReferencedColumn(beanTable);
 if (!order) {
  reverse();
 }
}

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

assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table2", joinColumns[1].table() );
assertEquals( "", inverseJoinColumns[0].name() );
assertEquals( "", inverseJoinColumns[0].referencedColumnName() );
assertEquals( "", inverseJoinColumns[0].table() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertEquals( "table3", inverseJoinColumns[1].table() );

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

assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table2", joinColumns[1].table() );
assertEquals( "", inverseJoinColumns[0].name() );
assertEquals( "", inverseJoinColumns[0].referencedColumnName() );
assertEquals( "", inverseJoinColumns[0].table() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertEquals( "table3", inverseJoinColumns[1].table() );

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

assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table2", joinColumns[1].table() );
assertEquals( "", inverseJoinColumns[0].name() );
assertEquals( "", inverseJoinColumns[0].referencedColumnName() );
assertEquals( "", inverseJoinColumns[0].table() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertEquals( "table3", inverseJoinColumns[1].table() );
assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col8", joinColumns[1].name() );
assertEquals( "col9", joinColumns[1].referencedColumnName() );
assertEquals( "table4", joinColumns[1].table() );

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

assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table2", joinColumns[1].table() );

代码示例来源:origin: org.hibernate/hibernate-annotations

public void setJoinAnnotation(JoinColumn annJoin, String defaultName) {
  if ( annJoin == null ) {
    setImplicit( true );
  }
  else {
    setImplicit( false );
    if ( !BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
    if ( !BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
    setNullable( annJoin.nullable() );
    setUnique( annJoin.unique() );
    setInsertable( annJoin.insertable() );
    setUpdatable( annJoin.updatable() );
    setReferencedColumn( annJoin.referencedColumnName() );
    setSecondaryTableName( annJoin.table() );
  }
}

相关文章