本文整理了Java中javax.persistence.JoinColumn
类的一些代码示例,展示了JoinColumn
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JoinColumn
类的具体详情如下:
包路径:javax.persistence.JoinColumn
类名称:JoinColumn
暂无
代码示例来源:origin: hibernate/hibernate-orm
@Entity
public static class E1 {
@Id
@Column( columnDefinition = "`explicitly quoted`" )
private Integer id;
@ManyToOne
@JoinColumn( columnDefinition = "`explicitly quoted`" )
private E1 other;
}
代码示例来源: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
@Entity(name = "SpecialPerson")
public static class SpecialPerson extends Person {
@Column(name = "special")
private String special;
@OneToMany(orphanRemoval = true, cascade = {
CascadeType.PERSIST,
CascadeType.REMOVE
})
@JoinColumn(name = "PERSONID", referencedColumnName = "ID", nullable = false, updatable = false)
@BatchSize(size = 100)
private Set<Address> addresses = new HashSet<Address>();
public void addAddress(Address address) {
this.addresses.add( address );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@ElementCollection( targetClass = String.class, fetch = FetchType.EAGER )
@CollectionType( type = "DefaultableList" )
@JoinColumn( name = "ENT_ID" )
@OrderColumn( name = "POS" )
@Column(name = "VAL")
public List getValues() {
return values;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* @author Emmanuel Bernard
*/
@Entity
public class Dependent {
@EmbeddedId
DependentId id;
@MapsId("empPK")
@ManyToOne
@JoinColumns( { @JoinColumn(nullable = false), @JoinColumn(nullable = false) })
Employee emp;
}
代码示例来源:origin: hibernate/hibernate-orm
@ManyToOne
@JoinColumn(name="replacement_order_nbr", table="OrderLine_Extension", referencedColumnName = "order_nbr")
public Order getReplacementOrder() {
return replacementOrder;
}
代码示例来源:origin: hibernate/hibernate-orm
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.columnDefinition() ) ) {
setSqlType( getBuildingContext().getObjectNameNormalizer().applyGlobalQuoting( 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() );
if ( BinderHelper.isEmptyAnnotationValue( annJoin.table() ) ) {
setExplicitTableName( "" );
final Identifier logicalIdentifier = getBuildingContext().getMetadataCollector()
.getDatabase()
.toIdentifier( annJoin.table() );
final Identifier physicalIdentifier = getBuildingContext().getBuildingOptions()
.getPhysicalNamingStrategy()
代码示例来源:origin: hibernate/hibernate-orm
String columnName = element.getAnnotation( Column.class ).name();
for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
if ( !prop.isAnnotationPresent( MapsId.class ) ) {
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: 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: hibernate/hibernate-orm
colName = joinAnn.name();
columnDefinition = joinAnn.columnDefinition();
referencedColumnName = joinAnn.referencedColumnName();
代码示例来源:origin: hibernate/hibernate-orm
/**
* @author Emmanuel Bernard
*/
@Entity
@AssociationOverrides({
@AssociationOverride(name = "id.channel", joinColumns = @JoinColumn(name = "chan_id", nullable = false)),
@AssociationOverride(name = "id.presenter", joinColumns = @JoinColumn(name = "presenter_name", nullable = false))})
public class TvMagazin {
@EmbeddedId
public TvMagazinPk id;
@Temporal(TemporalType.TIME)
@Column(name="`time`")
Date time;
}
代码示例来源:origin: hibernate/hibernate-orm
@ElementCollection
@CollectionTable(
name = "MATERIAL_RATINGS",
joinColumns = { @JoinColumn( name = "MATERIAL_ID" ) }
)
@Column( name="RATING")
@Immutable
public Set<String> getRatings() {
return ratings;
}
public void setRatings(Set<String> ratings) {
代码示例来源:origin: hibernate/hibernate-orm
/**
* @author Emmanuel Bernard
*/
@Entity
public class Dependent {
@EmbeddedId
DependentId id;
//@JoinColumn(name="FK") // id attribute mapped by join column default
@MapsId("empPK") // maps empPK attribute of embedded id
@ManyToOne
@JoinColumn(nullable=false)
Employee emp;
}
代码示例来源:origin: hibernate/hibernate-orm
@Embeddable
public static class Id implements Serializable {
@ManyToOne
@JoinColumn
private Movie movie;
@ManyToOne
@JoinColumn
private Theater theater;
}
代码示例来源: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
.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
if ( prop.isAnnotationPresent( Id.class ) && prop.isAnnotationPresent( Column.class ) ) {
columnName = prop.getAnnotation( Column.class ).name();
&& ! BinderHelper.isEmptyAnnotationValue( joinColumn.name() )
&& joinColumn.name().equals( columnName )
&& !property.isAnnotationPresent( MapsId.class ) ) {
hasSpecjManyToOne = true;
代码示例来源:origin: hibernate/hibernate-orm
@Entity
public static class E2 {
@Id
@Column( columnDefinition = "not explicitly quoted" )
private Integer id;
@ManyToOne
@JoinColumn( columnDefinition = "not explicitly quoted" )
private E2 other;
}
}
代码示例来源:origin: hibernate/hibernate-orm
@ElementCollection
@CollectionTable(
name = "COLLECTION_TABLE",
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
)
@Column( name="VALUE")
@Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'")
@Immutable
public Set<String> getSizesFromCombined() {
return sizesFromCombined;
}
public void setSizesFromCombined(Set<String> sizesFromCombined) {
代码示例来源:origin: hibernate/hibernate-orm
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "parentName"),
@JoinColumn(name = "parentLevel")
})
public Node getParent() {
return parent;
}
内容来源于网络,如有侵权,请联系作者删除!