本文整理了Java中javax.persistence.JoinColumn.unique()
方法的一些代码示例,展示了JoinColumn.unique()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JoinColumn.unique()
方法的具体详情如下:
包路径:javax.persistence.JoinColumn
类名称:JoinColumn
方法名:unique
暂无
代码示例来源: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
setUnique( annJoin.unique() );
setInsertable( annJoin.insertable() );
setUpdatable( annJoin.updatable() );
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col8", joinColumns[1].name() );
assertEquals( "col9", joinColumns[1].referencedColumnName() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
代码示例来源: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: org.apache.openjpa/com.springsource.org.apache.openjpa
/**
* Parse given @JoinColumn annotations.
*/
private void parseJoinColumns(FieldMapping fm, MappingInfo info,
boolean secondaryAllowed, JoinColumn... joins) {
if (joins.length == 0)
return;
List<Column> cols = new ArrayList<Column>(joins.length);
int unique = 0;
String secondary = null;
for (int i = 0; i < joins.length; i++) {
cols.add(newColumn(joins[i]));
unique |= (joins[i].unique()) ? TRUE : FALSE;
secondary = trackSecondaryTable(fm, secondary,
joins[i].table(), i);
if (!secondaryAllowed && secondary != null)
throw new MetaDataException(_loc.get("bad-second", fm));
}
setColumns(fm, info, cols, unique);
if (secondary != null)
fm.getMappingInfo().setTableName(secondary);
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
/**
* Parse @AssociationOverride(s).
*/
private void parseAssociationOverrides(ClassMapping cm,
AssociationOverride... assocs) {
FieldMapping sup;
JoinColumn[] scols;
int unique;
List<Column> jcols;
for (AssociationOverride assoc : assocs) {
if (StringUtils.isEmpty(assoc.name()))
throw new MetaDataException(_loc.get("no-override-name", cm));
sup = (FieldMapping) cm.getDefinedSuperclassField(assoc.name());
if (sup == null)
sup = (FieldMapping) cm.addDefinedSuperclassField
(assoc.name(), Object.class, Object.class);
scols = assoc.joinColumns();
if (scols == null || scols.length == 0)
continue;
jcols = new ArrayList<Column>(scols.length);
unique = 0;
for (JoinColumn scol : scols) {
unique |= (scol.unique()) ? TRUE : FALSE;
jcols.add(newColumn(scol));
}
setColumns(sup, sup.getValueInfo(), jcols, unique);
}
}
代码示例来源:origin: org.batoo.jpa/batoo-jpa
/**
* @param locator
* the locator
* @param annotation
* the annotation
*
* @since 2.0.0
*/
public JoinColumnMetadataImpl(AbstractLocator locator, JoinColumn annotation) {
super();
this.locator = locator;
this.columnDefinition = annotation.columnDefinition();
this.insertable = annotation.insertable();
this.name = annotation.name();
this.nullable = annotation.nullable();
this.referencedColumnName = annotation.referencedColumnName();
this.table = annotation.table();
this.unique = annotation.unique();
this.updatable = annotation.updatable();
}
代码示例来源:origin: BatooOrg/BatooJPA
/**
* @param locator
* the locator
* @param annotation
* the annotation
*
* @since 2.0.0
*/
public JoinColumnMetadataImpl(AbstractLocator locator, JoinColumn annotation) {
super();
this.locator = locator;
this.columnDefinition = annotation.columnDefinition();
this.insertable = annotation.insertable();
this.name = annotation.name();
this.nullable = annotation.nullable();
this.referencedColumnName = annotation.referencedColumnName();
this.table = annotation.table();
this.unique = annotation.unique();
this.updatable = annotation.updatable();
}
代码示例来源:origin: org.batoo.jpa/parser
/**
* @param locator
* the locator
* @param annotation
* the annotation
*
* @since 2.0.0
*/
public JoinColumnMetadataImpl(AbstractLocator locator, JoinColumn annotation) {
super();
this.locator = locator;
this.columnDefinition = annotation.columnDefinition();
this.insertable = annotation.insertable();
this.name = annotation.name();
this.nullable = annotation.nullable();
this.referencedColumnName = annotation.referencedColumnName();
this.table = annotation.table();
this.unique = annotation.unique();
this.updatable = annotation.updatable();
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
/**
* Parse given @AssociationOverride annotations on an embedded mapping.
*/
private void parseAssociationOverrides(FieldMapping fm,
AssociationOverride... assocs) {
ClassMapping embed = fm.getEmbeddedMapping();
if (embed == null)
throw new MetaDataException(_loc.get("not-embedded", fm));
FieldMapping efm;
JoinColumn[] ecols;
int unique;
List<Column> jcols;
for (AssociationOverride assoc : assocs) {
efm = embed.getFieldMapping(assoc.name());
if (efm == null)
throw new MetaDataException(_loc.get("embed-override-name",
fm, assoc.name()));
ecols = assoc.joinColumns();
if (ecols == null || ecols.length == 0)
continue;
unique = 0;
jcols = new ArrayList<Column>(ecols.length);
for (JoinColumn ecol : ecols) {
unique |= (ecol.unique()) ? TRUE : FALSE;
jcols.add(newColumn(ecol));
}
setColumns(efm, efm.getValueInfo(), jcols, unique);
}
}
代码示例来源: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: org.apache.openjpa/openjpa-all
jcols = new ArrayList<Column>(ecols.length);
for (JoinColumn ecol : ecols) {
unique |= (ecol.unique()) ? TRUE : FALSE;
jcols.add(newColumn(ecol));
代码示例来源: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: toplink.essentials/toplink-essentials
/**
* INTERNAL:
* Called for association override.
*/
public MetadataJoinColumn(JoinColumn joinColumn) {
this();
if (joinColumn != null) {
// Process the primary key field metadata.
m_pkField.setName(joinColumn.referencedColumnName());
// Process the foreign key field metadata.
m_fkField.setName(joinColumn.name());
m_fkField.setTableName(joinColumn.table());
m_fkField.setUnique(joinColumn.unique());
m_fkField.setNullable(joinColumn.nullable());
m_fkField.setUpdatable(joinColumn.updatable());
m_fkField.setInsertable(joinColumn.insertable());
m_fkField.setColumnDefinition(joinColumn.columnDefinition());
}
}
代码示例来源: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.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() );
}
}
内容来源于网络,如有侵权,请联系作者删除!