Last active
August 29, 2015 14:01
-
-
Save walshe/ca1d6b0d1f7602b4d21f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cassidian.ip.data | |
import groovy.transform.EqualsAndHashCode | |
import org.hibernate.validator.constraints.NotEmpty | |
import javax.persistence.* | |
import javax.validation.constraints.NotNull | |
@Entity | |
@EqualsAndHashCode(includes=['activationUUID','target']) | |
@IdClass(SelectedTargetPK.class) | |
class SelectedTarget { | |
@Id | |
UUID activationUUID | |
@Id | |
@OneToOne(fetch = FetchType.EAGER) | |
@JoinColumn(name = "target_id") | |
@NotNull | |
Target target | |
int targetTypeId | |
@NotEmpty | |
@OneToMany(fetch=FetchType.EAGER, cascade= [CascadeType.ALL]) | |
@JoinTable( | |
joinColumns = | |
[ | |
@JoinColumn(name="selected_target_activationuuid", referencedColumnName="activationuuid"), | |
@JoinColumn(name="selected_target_target_id", referencedColumnName="target_id") | |
], | |
inverseJoinColumns = | |
[ | |
@JoinColumn(name="selected_source_activationuuid",referencedColumnName="activationuuid"), | |
@JoinColumn(name="selected_source_source_type",referencedColumnName="source_type"), | |
@JoinColumn(name="selected_source_source_id",referencedColumnName="source_id"), | |
] | |
) | |
Set<SelectedSource> sources = [] as Set | |
int primarySourceId | |
} | |
@EqualsAndHashCode | |
class SelectedTargetPK implements Serializable{ | |
UUID activationUUID | |
Target target | |
} | |
package com.cassidian.ip.data | |
import groovy.transform.EqualsAndHashCode | |
import javax.persistence.EmbeddedId | |
import javax.persistence.Entity | |
import javax.persistence.EnumType | |
import javax.persistence.Enumerated | |
import javax.persistence.Id | |
import javax.persistence.IdClass | |
import javax.persistence.JoinColumn | |
import javax.persistence.JoinColumns | |
import javax.persistence.ManyToOne | |
@Entity | |
@EqualsAndHashCode(includes=['activationUUID','sourceType','sourceId']) | |
@IdClass(SelectedSourcePK.class) | |
class SelectedSource { | |
@Id | |
UUID activationUUID | |
@Id | |
@Enumerated(EnumType.ORDINAL) | |
SourceType sourceType | |
@Id | |
long sourceId | |
//@ManyToOne | |
//@JoinColumns([ @JoinColumn(name="selected_target_activationuuid"),@JoinColumn(name="selected_target_target_id")]) | |
//SelectedTarget selectedTarget | |
} | |
@EqualsAndHashCode | |
class SelectedSourcePK implements Serializable{ | |
UUID activationUUID | |
SourceType sourceType | |
long sourceId | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment