javax.persistence.ForeignKey Java Examples

The following examples show how to use javax.persistence.ForeignKey. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPropertyHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ForeignKey getOverriddenForeignKey(String propertyName) {
	ForeignKey result = getExactOverriddenForeignKey( propertyName );
	if ( result == null && propertyName.contains( ".collection&&element." ) ) {
		//support for non map collections where no prefix is needed
		//TODO cache the underlying regexp
		result = getExactOverriddenForeignKey( propertyName.replace( ".collection&&element.", "." ) );
	}
	return result;
}
 
Example #2
Source File: AbstractPropertyHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ForeignKey getExactOverriddenForeignKey(String propertyName) {
	ForeignKey override = null;
	if ( parent != null ) {
		override = parent.getExactOverriddenForeignKey( propertyName );
	}
	if ( override == null && currentPropertyForeignKeyOverride != null ) {
		override = currentPropertyForeignKeyOverride.get( propertyName );
	}
	if ( override == null && holderForeignKeyOverride != null ) {
		override = holderForeignKeyOverride.get( propertyName );
	}
	return override;
}
 
Example #3
Source File: AbstractPropertyHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void buildHierarchyColumnOverride(XClass element) {
	XClass current = element;
	Map<String, Column[]> columnOverride = new HashMap<String, Column[]>();
	Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>();
	Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>();
	Map<String, ForeignKey> foreignKeyOverride = new HashMap<String, ForeignKey>();
	while ( current != null && !context.getBootstrapContext().getReflectionManager().toXClass( Object.class ).equals( current ) ) {
		if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class )
				|| current.isAnnotationPresent( Embeddable.class ) ) {
			//FIXME is embeddable override?
			Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() );
			Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() );
			Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath() );
			Map<String, ForeignKey> currentForeignKeyOverride = buildForeignKeyOverride( current, getPath() );
			currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
			currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
			currentJoinTableOverride.putAll( joinTableOverride ); //subclasses have precedence over superclasses
			currentForeignKeyOverride.putAll( foreignKeyOverride ); //subclasses have precedence over superclasses
			columnOverride = currentOverride;
			joinColumnOverride = currentJoinOverride;
			joinTableOverride = currentJoinTableOverride;
			foreignKeyOverride = currentForeignKeyOverride;
		}
		current = current.getSuperclass();
	}

	holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null;
	holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null;
	holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null;
	holderForeignKeyOverride = foreignKeyOverride.size() > 0 ? foreignKeyOverride : null;
}
 
Example #4
Source File: AbstractPropertyHolder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static Map<String, ForeignKey> buildForeignKeyOverride(XAnnotatedElement element, String path) {
	Map<String, ForeignKey> foreignKeyOverride = new HashMap<String, ForeignKey>();
	if ( element != null ) {
		AssociationOverride[] overrides = buildAssociationOverrides( element, path );
		if ( overrides != null ) {
			for ( AssociationOverride depAttr : overrides ) {
				foreignKeyOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.foreignKey() );
			}
		}
	}
	return foreignKeyOverride;
}
 
Example #5
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #7
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #9
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #10
Source File: TaskData.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #11
Source File: PropertyHolder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * return null if hte foreign key is not overridden, or the foreign key if true
 */
default ForeignKey getOverriddenForeignKey(String propertyName) {
	// todo: does this necessarily need to be a default method?
	return null;
}
 
Example #12
Source File: MapKeyJoinColumnDelegator.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ForeignKey foreignKey() {
	return column.foreignKey();
}
 
Example #13
Source File: Person.java    From requery with Apache License 2.0 4 votes vote down vote up
@OneToOne(cascade = CascadeType.PERSIST)
@JoinColumn(foreignKey = @ForeignKey)
Address getAddress();
 
Example #14
Source File: Phone.java    From requery with Apache License 2.0 4 votes vote down vote up
@JoinColumn(foreignKey = @ForeignKey, table = "Person")
public abstract int getOwnerId();