本文整理了Java中javax.persistence.JoinTable
类的一些代码示例,展示了JoinTable
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JoinTable
类的具体详情如下:
包路径:javax.persistence.JoinTable
类名称:JoinTable
暂无
代码示例来源:origin: spring-projects/spring-petclinic
@Entity
@Table(name = "vets")
public class Vet extends Person {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
private Set<Specialty> specialties;
代码示例来源: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: requery/requery
@Override
public String name() {
return table.name();
}
代码示例来源:origin: hibernate/hibernate-orm
@Entity
public class Address {
@Id
private long id;
@ManyToOne
@JoinTable(name = "person_address")
private Person person;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
}
代码示例来源:origin: hibernate/hibernate-orm
public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisionEntity {
@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME")
@Fetch(FetchMode.JOIN)
@ModifiedEntityNames
代码示例来源:origin: hibernate/hibernate-orm
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(
name = "StoreSupplier",
joinColumns = @JoinColumn(name = "store"),
inverseJoinColumns = @JoinColumn(name = "supplier")
)
public Set<Supplier> getSuppliers() {
return suppliers;
}
代码示例来源:origin: hibernate/hibernate-orm
@ElementCollection
// HHH-7732 -- "EntityWithAnElementCollection_someStrings" is too long for Oracle.
@JoinTable(
name = "SomeStrings",
joinColumns = @JoinColumn( name = "EWAEC_ID") )
public Set<String> getSomeStrings() {
return someStrings;
}
代码示例来源:origin: hibernate/hibernate-orm
@ManyToMany( cascade = CascadeType.ALL )
@JoinTable( name = "CHARACTER_ALIAS", indexes = @Index( columnList = "characters_id"))
// @JoinTable(
// name = "CHARACTER_ALIAS",
// joinColumns = @JoinColumn(name="ALIAS_ID", referencedColumnName="ID"),
// inverseJoinColumns = @JoinColumn(name="CHARACTER_ID", referencedColumnName="ID")
// )
public List<Character> getCharacters() {
return characters;
}
代码示例来源:origin: hibernate/hibernate-orm
assertAnnotationNotPresent( JoinColumn.class );
JoinTable joinTableAnno = reader.getAnnotation( JoinTable.class );
assertEquals( "cat1", joinTableAnno.catalog() );
assertEquals( "table1", joinTableAnno.name() );
assertEquals( "schema1", joinTableAnno.schema() );
JoinColumn[] joinColumns = joinTableAnno.joinColumns();
assertEquals( 2, joinColumns.length );
assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertEquals( "", joinColumns[0].columnDefinition() );
assertTrue( joinColumns[0].insertable() );
JoinColumn[] inverseJoinColumns = joinTableAnno.inverseJoinColumns();
assertEquals( 2, inverseJoinColumns.length );
assertEquals( "", inverseJoinColumns[0].name() );
.uniqueConstraints();
assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testJoinTableNoChildren() throws Exception {
reader = getReader( Entity2.class, "field1", "many-to-many.orm16.xml" );
assertAnnotationPresent( ManyToMany.class );
assertAnnotationPresent( JoinTable.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
JoinTable joinTableAnno = reader.getAnnotation( JoinTable.class );
assertEquals( "", joinTableAnno.catalog() );
assertEquals( "", joinTableAnno.name() );
assertEquals( "", joinTableAnno.schema() );
assertEquals( 0, joinTableAnno.joinColumns().length );
assertEquals( 0, joinTableAnno.inverseJoinColumns().length );
assertEquals( 0, joinTableAnno.uniqueConstraints().length );
}
代码示例来源:origin: hibernate/hibernate-orm
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name="Tree_Forest")
public ForestType getForestType() {
return forestType;
}
代码示例来源:origin: ebean-orm/ebean
if (column != null && !isEmpty(column.name())) {
prop.setDbColumn(column.name());
if (!joinColumn.updatable()) {
prop.setDbUpdateable(false);
if (!joinColumn.nullable()) {
prop.setNullable(false);
for (JoinColumn joinColumn : joinTable.joinColumns()) {
if (beanTable == null) {
throw new IllegalStateException("Looks like a missing @ManyToOne or @OneToOne on property " + prop.getFullBeanName()+" - no related 'BeanTable'");
if (!joinColumn.updatable()) {
prop.setDbUpdateable(false);
代码示例来源:origin: hibernate/hibernate-orm
if ( joinTableAnn != null ) {
joinColumns = Ejb3JoinColumn.buildJoinColumns(
joinTableAnn.inverseJoinColumns(),
null,
entityBinder.getSecondaryTables(),
buildingContext
);
if ( StringHelper.isEmpty( joinTableAnn.name() ) ) {
throw new AnnotationException(
"JoinTable.name() on a @ToOne association has to be explicit: "
代码示例来源:origin: ebean-orm/ebean
/**
* Return the full table name
*/
private String getFullTableName(JoinTable joinTable) {
StringBuilder sb = new StringBuilder();
if (!StringHelper.isNull(joinTable.catalog())) {
sb.append(joinTable.catalog()).append(".");
}
if (!StringHelper.isNull(joinTable.schema())) {
sb.append(joinTable.schema()).append(".");
}
sb.append(joinTable.name());
return sb.toString();
}
代码示例来源:origin: ebean-orm/ebean
/**
* Define the joins for a ManyToMany relationship.
* <p>
* This includes joins to the intersection table and from the intersection table
* to the other side of the ManyToMany.
* </p>
*/
private void readJoinTable(JoinTable joinTable, DeployBeanPropertyAssocMany<?> prop) {
String intTableName = getFullTableName(joinTable);
if (intTableName.isEmpty()) {
BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
BeanTable otherTable = factory.getBeanTable(prop.getTargetType());
intTableName = getM2MJoinTableName(localTable, otherTable);
}
// set the intersection table
DeployTableJoin intJoin = new DeployTableJoin();
intJoin.setTable(intTableName);
// add the source to intersection join columns
intJoin.addJoinColumn(true, joinTable.joinColumns(), prop.getBeanTable());
// set the intersection to dest table join columns
DeployTableJoin destJoin = prop.getTableJoin();
destJoin.addJoinColumn(false, joinTable.inverseJoinColumns(), prop.getBeanTable());
intJoin.setType(SqlJoinType.OUTER);
// reverse join from dest back to intersection
DeployTableJoin inverseDest = destJoin.createInverse(intTableName);
prop.setIntersectionJoin(intJoin);
prop.setInverseJoin(inverseDest);
}
代码示例来源:origin: hibernate/hibernate-orm
collectionTableAnn.joinColumns().length == 1 ) {
JoinColumn joinColumn = collectionTableAnn.joinColumns()[0];
key.setForeignKeyName( StringHelper.nullIfEmpty( joinColumn.foreignKey().name() ) );
key.setForeignKeyDefinition( StringHelper.nullIfEmpty( joinColumn.foreignKey().foreignKeyDefinition() ) );
final JoinTable joinTableAnn = property.getAnnotation( JoinTable.class );
if ( joinTableAnn != null ) {
String foreignKeyName = joinTableAnn.foreignKey().name();
String foreignKeyDefinition = joinTableAnn.foreignKey().foreignKeyDefinition();
ConstraintMode foreignKeyValue = joinTableAnn.foreignKey().value();
if ( joinTableAnn.joinColumns().length != 0 ) {
final JoinColumn joinColumnAnn = joinTableAnn.joinColumns()[0];
if ( "".equals( foreignKeyName ) ) {
foreignKeyName = joinColumnAnn.foreignKey().name();
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
代码示例来源:origin: hibernate/hibernate-orm
if ( joinTableAnn != null && joinTableAnn.inverseJoinColumns().length > 0 ) {
String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
throw new AnnotationException(
final JoinTable joinTableAnn = property.getAnnotation( JoinTable.class );
if ( joinTableAnn != null ) {
String foreignKeyName = joinTableAnn.inverseForeignKey().name();
String foreignKeyDefinition = joinTableAnn.inverseForeignKey().foreignKeyDefinition();
ConstraintMode foreignKeyValue = joinTableAnn.inverseForeignKey().value();
if ( joinTableAnn.inverseJoinColumns().length != 0 ) {
final JoinColumn joinColumnAnn = joinTableAnn.inverseJoinColumns()[0];
if ( "".equals( foreignKeyName ) ) {
foreignKeyName = joinColumnAnn.foreignKey().name();
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
foreignKeyValue = joinColumnAnn.foreignKey().value();
if ( joinTableAnn.inverseForeignKey().value() == ConstraintMode.NO_CONSTRAINT ) {
element.setForeignKeyName( "none" );
代码示例来源:origin: org.hibernate/hibernate-annotations
if ( joinTableAnn != null && joinTableAnn.inverseJoinColumns().length > 0 ) {
String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
throw new AnnotationException(
代码示例来源:origin: hibernate/hibernate-orm
@Entity
public class Attrset {
@Id
@GeneratedValue
private Long id;
@OneToMany
@JoinTable(name = "ATTRSET_X_ATTRVALUE")
private Set<Attrvalue> attrvalues = new HashSet<Attrvalue>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Set<Attrvalue> getAttrvalues() {
return attrvalues;
}
public void setAttrvalues(Set<Attrvalue> attrvalues) {
this.attrvalues = attrvalues;
}
}
代码示例来源:origin: hibernate/hibernate-orm
public class SequenceIdTrackingModifiedEntitiesRevisionEntity extends SequenceIdRevisionEntity {
@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME")
@Fetch(FetchMode.JOIN)
@ModifiedEntityNames
内容来源于网络,如有侵权,请联系作者删除!