下面列出了javax.persistence.CascadeType#REMOVE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@ElementCollection(fetch = FetchType.EAGER)
@OneToMany(mappedBy="raceAward",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@OrderColumn(name = "category_priority")
public List<AwardCategory> getAwardCategories(){
return awardCategories;
}
@OneToMany(mappedBy="race",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@OrderBy("split_seq_number")
@Fetch(FetchMode.SELECT)
public List<Split> getSplits() {
return raceSplitList;
//return raceSplits.sorted((Split o1, Split o2) -> o1.getPosition().compareTo(o2.getPosition()));
}
private static boolean needsToCascade(Field field) {
Class<?> fieldtype = field.getType();
if (!DomainObject.class.isAssignableFrom(fieldtype))
return false;
Annotation ann;
CascadeType[] cascades = null;
ann = field.getAnnotation(OneToOne.class);
if (ann != null) {
cascades = ((OneToOne) ann).cascade();
} else {
ann = field.getAnnotation(OneToMany.class);
if (ann != null) {
cascades = ((OneToMany) ann).cascade();
} else {
ann = field.getAnnotation(ManyToOne.class);
if (ann != null) {
cascades = ((ManyToOne) ann).cascade();
} else {
ann = field.getAnnotation(ManyToMany.class);
if (ann != null) {
cascades = ((ManyToMany) ann).cascade();
}
}
}
}
if (cascades == null)
return false;
for (CascadeType cas : cascades) {
if ((cas == CascadeType.ALL) || (cas == CascadeType.MERGE)
|| (cas == CascadeType.PERSIST)
|| (cas == CascadeType.REMOVE)) {
return true;
}
}
return false;
}
/**
* @return the configuration
*/
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({
@JoinColumn(name = "clusterId", referencedColumnName = "clusterId"),
@JoinColumn(name = "host", referencedColumnName = "publicIp") })
public List<Configuration> getConfiguration() {
return configuration;
}
@OneToMany(mappedBy="race",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
public List<Wave> getWaves() {
return raceWavesList;
}
/**
* Gets the logs.
*
* @return the logs
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<Log> getLogs() {
return logs;
}
@OneToMany(mappedBy="raceReport",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.LAZY)
@Fetch(FetchMode.SELECT)
public List<RaceOutputTarget> getRaceOutputTargets() {
return raceOutputTargetList;
}
/**
*方法: 取得java.lang.String
*@return: java.lang.String 老师主键
*/
@ManyToOne(cascade=CascadeType.REMOVE)
public TeacherEntity getTeacher() {
return teacher;
}
@OneToMany(mappedBy="course",cascade=CascadeType.REMOVE)
public List<StudentEntity> getStudents() {
return students;
}
@OneToMany(cascade=CascadeType.REMOVE,mappedBy="table")
public List<CgFormIndexEntity> getIndexes() {
return indexes;
}
@OneToMany(cascade=CascadeType.REMOVE,mappedBy="table")
@OrderBy(clause="orderNum asc")
public List<CgFormFieldEntity> getColumns() {
return columns;
}
@OneToMany(mappedBy = "owner", cascade =
{CascadeType.REMOVE, CascadeType.PERSIST})
MutableResult<Phone> getPhoneNumbers();
/**
* Gets the nodes.
*
* @return the nodes
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
@JsonIgnore
public Set<Node> getNodes() {
return nodes;
}
/**
* @return the configuration
*/
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumns({ @JoinColumn(name = "node", referencedColumnName = "publicIp") })
public List<Service> getServices() {
return services;
}
/**
* Gets the monitors.
*
* @return the monitors
*/
@OneToMany(mappedBy = "nodeId", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<NodeMonitoring> getMonitors() {
return monitors;
}
/**
* @return the haServices
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<Service> getServices() {
return services;
}
/**
* @return the haServices
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<HAService> getHaServices() {
return haServices;
}
/**
* @return the operations
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<Operation> getOperations() {
return operations;
}
/**
* Gets the configurations.
*
* @return the configurations
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<Configuration> getConfigurations() {
return configurations;
}
/**
* Gets the events.
*
* @return the events
*/
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
public List<Event> getEvents() {
return events;
}