@ManyToOne(fetch = FetchType.EAGER) @ForeignKey(name="BODY_COLOR_FK") public Color getBodyColor() { return bodyColor; }
private void setFKNameIfDefined(Join join) { // just awful.. org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join ); if ( matchingTable != null && !BinderHelper.isEmptyAnnotationValue( matchingTable.foreignKey().name() ) ) { ( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() ); } else { javax.persistence.SecondaryTable jpaSecondaryTable = findMatchingSecondaryTable( join ); if ( jpaSecondaryTable != null ) { if ( jpaSecondaryTable.foreignKey().value() == ConstraintMode.NO_CONSTRAINT ) { ( (SimpleValue) join.getKey() ).setForeignKeyName( "none" ); } else { ( (SimpleValue) join.getKey() ).setForeignKeyName( StringHelper.nullIfEmpty( jpaSecondaryTable.foreignKey().name() ) ); ( (SimpleValue) join.getKey() ).setForeignKeyDefinition( StringHelper.nullIfEmpty( jpaSecondaryTable.foreignKey().foreignKeyDefinition() ) ); } } } }
String fkName = fk != null ? fk.inverseName() : ""; if ( !BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
@OneToMany @JoinTable( name = "TrainedMonkeys", //columns are optional, here we explicit them joinColumns = @JoinColumn(name = "trainer_id"), inverseJoinColumns = @JoinColumn(name = "monkey_id") ) @ForeignKey(name = "TM_TRA_FK", inverseName = "TM_MON_FK") public Set<Monkey> getTrainedMonkeys() { return trainedMonkeys; }
@Entity @Table(name = "Employee") public class Employee { @EmbeddedId @ForeignKey(name = "none") private EmployeeId id; @ManyToOne(optional = true) @ForeignKey(name = "none") private Employee manager; }
private void setFKNameIfDefined(Join join) { org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join ); if ( matchingTable != null && !BinderHelper.isDefault( matchingTable.foreignKey().name() ) ) { ( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() ); } }
@OneToMany @JoinColumn(name = "mainstreetcity_id") @ForeignKey(name = "CITYSTR_FK") @OrderBy @Immutable public List<Street> getMainStreets() { return mainStreets; }
@ForeignKey(name = "FK_LEFT_PERSON") private Person left; @ForeignKey(name = "FK_RIGHT_PERSON") private Person right;
@ForeignKey(name = "FK_PAIR_SET") private final Set<PersonPair> pairs = new HashSet<PersonPair>(0);
@ForeignKey(name = "FK_RE2_MCE") @NotAudited private MultipleCollectionEntity multipleCollectionEntity;
collValue.setKey( key ); ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null; String fkName = fk != null ? fk.name() : ""; if ( !BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName ); return key;
@ForeignKey(name = "FK_RE1_MCE") @NotAudited private MultipleCollectionEntity multipleCollectionEntity;
@Table(appliesTo = "Cat", indexes = @Index(name = "secondname", columnNames = "secondName"), comment = "My cat table" ) @Table(appliesTo = "Cat2", foreignKey = @ForeignKey(name="FK_CAT2_CAT"), fetch = FetchMode.SELECT, sqlInsert=@SQLInsert(sql="insert into Cat2(storyPart2, id) values(upper(?), ?)") ) public class Cat implements Serializable {
String fkName = fk != null ? fk.name() : ""; if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
/** * Getter for property 'componentParameters'. * * @return list of items for property 'componentParameters'. */ @OneToMany( mappedBy = "component", orphanRemoval = true, cascade = {CascadeType.PERSIST, CascadeType.REMOVE} ) @ForeignKey(name="FK_COMPONENT_PARAMETER") public Collection<ComponentParameter> getParameters() { return this.componentParameters; }