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

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

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

JoinColumn.nullable介绍

暂无

代码示例

代码示例来源: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: hibernate/hibernate-orm

setLogicalColumnName( annJoin.name() );
setNullable( annJoin.nullable() );
setUnique( annJoin.unique() );
setInsertable( annJoin.insertable() );

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

assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].insertable() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertFalse( inverseJoinColumns[1].insertable() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );

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

assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].insertable() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertFalse( inverseJoinColumns[1].insertable() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );
assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col8", joinColumns[1].name() );
assertFalse( joinColumns[1].insertable() );

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

assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].insertable() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertFalse( inverseJoinColumns[1].insertable() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );

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

assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );

代码示例来源:origin: io.github.itfinally/mybatis-jpa

private boolean isNullable() {
  return joinColumn != null ? joinColumn.nullable() : column.nullable();
}

代码示例来源:origin: br.com.jarch/jarch-jpa

private static String generateLeftJoin(Class<?> clazzEvaluate, boolean fetch) {
  StringBuilder leftJoin = new StringBuilder();
  for (Field field : clazzEvaluate.getDeclaredFields()) {
    if (!needJoin(field)) {
      continue;
    }
    String atributo = field.getName();
    JoinColumn joinColumn = field.getAnnotation(JoinColumn.class);
    boolean left = Collection.class.isAssignableFrom(field.getType()) || joinColumn == null || joinColumn.nullable();
    leftJoin.append((left ? "LEFT " : "") + "JOIN " + (fetch ? "FETCH " : " ") + JpaUtils.aliasEntity(clazzEvaluate) + "." + atributo + " " + atributo + " ");
  }
  return leftJoin.toString();
}

代码示例来源: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() );
  }
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws NoSuchFieldException {
   System.out.println(isRequired(Employee.class, "email"));
}

private static boolean isRequired(Class<?> entity, String propertyName) throws NoSuchFieldException {
  Field property = entity.getDeclaredField(propertyName);

  final JoinColumn joinAnnotation = property.getAnnotation(JoinColumn.class);
  if (null != joinAnnotation) {
    return !joinAnnotation.nullable();
  }

  final Column columnAnnotation = property.getAnnotation(Column.class);
  if (null != columnAnnotation) {
    return !columnAnnotation.nullable();
  }

  return false;
}

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

prop.setDbUpdateable(false);
if (!joinColumn.nullable()) {
 prop.setNullable(false);
  prop.setDbUpdateable(false);
 if (!joinColumn.nullable()) {
  prop.setNullable(false);

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

/**
 * Create a new schema column with information from the given annotation.
 */
private static Column newColumn(JoinColumn join) {
  Column col = new Column();
  if (!StringUtils.isEmpty(join.name()))
    col.setName(join.name());
  if (!StringUtils.isEmpty(join.columnDefinition()))
    col.setTypeName(join.columnDefinition());
  if (!StringUtils.isEmpty(join.referencedColumnName()))
    col.setTarget(join.referencedColumnName());
  col.setNotNull(!join.nullable());
  col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
  col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable());
  return col;
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-jpa-processor-core

private SimpleProperty buildSimpleProperty(final Attribute<?, ?> jpaAttribute, final SimpleProperty simpleProperty,
  final JoinColumn joinColumn)
  throws ODataJPAModelException, ODataJPARuntimeException {
 boolean isForeignKey = joinColumn != null;
 JPAEdmNameBuilder.build(JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming, isForeignKey);
 EdmSimpleTypeKind simpleTypeKind = JPATypeConverter
   .convertToEdmSimpleType(jpaAttribute
     .getJavaType(), jpaAttribute);
 simpleProperty.setType(simpleTypeKind);
 Facets facets = JPAEdmFacets.createAndSet(jpaAttribute, simpleProperty);
 if(isForeignKey) {
  facets.setNullable(joinColumn.nullable());
 }
 return simpleProperty;
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
 * Create a new schema column with information from the given annotation.
 */
private Column newColumn(JoinColumn join) {
  Column col = new Column();
  if (!StringUtils.isEmpty(join.name()))
    col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit()));
  if (!StringUtils.isEmpty(join.columnDefinition()))
    col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition())); 
  String refColumnName = join.referencedColumnName();
  if (!StringUtils.isEmpty(refColumnName)) {
    setTargetIdentifier(col, refColumnName);
  }
  col.setNotNull(!join.nullable());
  col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
  col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable());
  return col;
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected void toXml(Element parentEl) {
  if (annotation == null)
    return;
  Element el = parentEl.addElement(getElementName());
  el.addAttribute("name", annotation.name());
  if (!StringUtils.isEmpty(annotation.referencedColumnName()))
    el.addAttribute("referenced-column-name", annotation.referencedColumnName());
  if (annotation.unique())
    el.addAttribute("unique", "true");
  if (!annotation.nullable())
    el.addAttribute("nullable", "false");
  if (!annotation.insertable())
    el.addAttribute("insertable", "false");
  if (!annotation.updatable())
    el.addAttribute("updatable", "false");
}

代码示例来源:origin: com.caucho/resin

public JoinColumnConfig(JoinColumn joinColumn)
{
 setName(joinColumn.name());
 setReferencedColumnName(joinColumn.referencedColumnName());
 setUnique(joinColumn.unique());
 setNullable(joinColumn.nullable());
 setInsertable(joinColumn.insertable());
 setUpdatable(joinColumn.updatable());
 setColumnDefinition(joinColumn.columnDefinition());
 setTable(joinColumn.table());
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

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() );
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Create a new schema column with information from the given annotation.
 */
private Column newColumn(JoinColumn join) {
  Column col = new Column();
  if (!StringUtil.isEmpty(join.name()))
    col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit()));
  if (!StringUtil.isEmpty(join.columnDefinition()))
    col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition())); 
  String refColumnName = join.referencedColumnName();
  if (!StringUtil.isEmpty(refColumnName)) {
    setTargetIdentifier(col, refColumnName);
  }
  col.setNotNull(!join.nullable());
  col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
  col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable());
  return col;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

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

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

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

相关文章