下面列出了怎么用javax.persistence.ConstraintMode的API类实例代码及写法,或者点击链接到github查看源代码。
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() ) );
}
}
}
}
private ReferentialAction mapConstraint(ConstraintMode constraint) {
switch (constraint) {
case NO_CONSTRAINT:
return ReferentialAction.NO_ACTION;
default:
case CONSTRAINT:
case PROVIDER_DEFAULT:
return ReferentialAction.CASCADE;
}
}
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "ENV_SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getEnvScript() {
return envScript;
}
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getScript() {
return script;
}
@Cascade(CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "PRE_SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getPreScript() {
return preScript;
}
@Cascade(CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "POST_SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getPostScript() {
return postScript;
}
@Cascade(CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "CLEAN_SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getCleanScript() {
return cleanScript;
}
@Cascade(CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY)
// disable foreign key, to be able to remove runtime data
@JoinColumn(name = "FLOW_SCRIPT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
public ScriptData getFlowScript() {
return flowScript;
}