当前位置:   article > 正文

记录一下 spring boot jpa 外连接的 EntityGraph 写法_spring entity graphs

spring entity graphs

实体类: 

  1. package com.jintel.ct.entity;
  2. import javax.persistence.*;
  3. import java.util.Date;
  4. import java.util.LinkedHashSet;
  5. import java.util.Set;
  6. /**
  7. * @date :2019/6/26
  8. */
  9. @NamedEntityGraph(
  10. name = "CXCustomeStudiesNctIdOne.leftJoinList",
  11. attributeNodes = {
  12. @NamedAttributeNode("conditionss"),
  13. @NamedAttributeNode("cxCustomeDesignss"),
  14. @NamedAttributeNode("cxCustomeFacilities"),
  15. @NamedAttributeNode("cxCustomeInterventionss"),
  16. @NamedAttributeNode("documentss"),
  17. @NamedAttributeNode("idInformations"),
  18. @NamedAttributeNode("outcomeMeasurementss"),
  19. @NamedAttributeNode("sponsorss")
  20. }
  21. )
  22. @Entity
  23. @Table(name = "ct_custom_studies")
  24. public class CXCustomeStudiesNctIdOne {
  25. @Id
  26. @Column(name = "nct_id")
  27. private String nctId;
  28. @Column(name = "title")
  29. private String title;
  30. @Column(name = "status")
  31. private String status;
  32. @Column(name = "study_type")
  33. private String studyType;
  34. @Column(name = "phase")
  35. private String phase;
  36. @Column(name = "enrollment")
  37. private Integer numberEnrolled;
  38. @Column(name = "start_date")
  39. private Date studyStart;
  40. @Column(name = "completion_date")
  41. private Date studyCompletion;
  42. @Column(name = "study_result")
  43. private String studyResult;
  44. @Column(name = "primary_completion_date")
  45. private Date primaryCompletion;
  46. @Column(name = "first_posted")
  47. private Date firstPosted;
  48. @Column(name = "last_update_posted")
  49. private Date lastUpdatePosted;
  50. @Column(name = "results_first_posted")
  51. private Date resultsFirstPosted;
  52. @Column(name = "acronym")
  53. private String titleAcronym;
  54. @Column(name = "url")
  55. private String url;
  56. @Column(name = "age")
  57. private String age;
  58. @Column(name = "gender")
  59. private String gender;
  60. @Column(name = "trial_create_date")
  61. private Date trialCreateDate;
  62. @Column(name = "update_date")
  63. private Date updateDate;
  64. @Column(name = "sampling_method")
  65. private String samplingMethod;
  66. @Column(name = "inclusion")
  67. private String inclusion;
  68. @Column(name = "exclusion")
  69. private String exclusion;
  70. @Column(name = "accept_healthy_vol")
  71. private String acceptHealthyVol;
  72. @Column(name = "brief_summary")
  73. private String briefSummary;
  74. @Column(name = "rank")
  75. private Integer rank;
  76. @Column(name = "scope")
  77. private String scope;
  78. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  79. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  80. private Set<Conditions> conditionss = new LinkedHashSet<>();
  81. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  82. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  83. private Set<CXCustomeDesigns> cxCustomeDesignss = new LinkedHashSet<>();
  84. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  85. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  86. private Set<CXCustomeFacilities> cxCustomeFacilities = new LinkedHashSet<>();
  87. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  88. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  89. private Set<CXCustomeInterventions> cxCustomeInterventionss = new LinkedHashSet<>();
  90. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  91. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  92. private Set<Documents> documentss = new LinkedHashSet<>();
  93. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  94. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  95. private Set<IdInformation> idInformations = new LinkedHashSet<>();
  96. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  97. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  98. private Set<OutcomeMeasurements> outcomeMeasurementss = new LinkedHashSet<>();
  99. @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
  100. @JoinColumn(name = "nct_id", referencedColumnName = "nct_id")
  101. private Set<Sponsors> sponsorss = new LinkedHashSet<>();
  102. public String getNctId() {
  103. return nctId;
  104. }
  105. public void setNctId(String nctId) {
  106. this.nctId = nctId;
  107. }
  108. public String getTitle() {
  109. return title;
  110. }
  111. public void setTitle(String title) {
  112. this.title = title;
  113. }
  114. public String getStatus() {
  115. return status;
  116. }
  117. public void setStatus(String status) {
  118. this.status = status;
  119. }
  120. public String getStudyType() {
  121. return studyType;
  122. }
  123. public void setStudyType(String studyType) {
  124. this.studyType = studyType;
  125. }
  126. public String getPhase() {
  127. return phase;
  128. }
  129. public void setPhase(String phase) {
  130. this.phase = phase;
  131. }
  132. public Integer getNumberEnrolled() {
  133. return numberEnrolled;
  134. }
  135. public void setNumberEnrolled(Integer numberEnrolled) {
  136. this.numberEnrolled = numberEnrolled;
  137. }
  138. public Date getStudyStart() {
  139. return studyStart;
  140. }
  141. public void setStudyStart(Date studyStart) {
  142. this.studyStart = studyStart;
  143. }
  144. public Date getStudyCompletion() {
  145. return studyCompletion;
  146. }
  147. public void setStudyCompletion(Date studyCompletion) {
  148. this.studyCompletion = studyCompletion;
  149. }
  150. public Date getPrimaryCompletion() {
  151. return primaryCompletion;
  152. }
  153. public void setPrimaryCompletion(Date primaryCompletion) {
  154. this.primaryCompletion = primaryCompletion;
  155. }
  156. public Date getFirstPosted() {
  157. return firstPosted;
  158. }
  159. public void setFirstPosted(Date firstPosted) {
  160. this.firstPosted = firstPosted;
  161. }
  162. public Date getLastUpdatePosted() {
  163. return lastUpdatePosted;
  164. }
  165. public void setLastUpdatePosted(Date lastUpdatePosted) {
  166. this.lastUpdatePosted = lastUpdatePosted;
  167. }
  168. public Date getResultsFirstPosted() {
  169. return resultsFirstPosted;
  170. }
  171. public void setResultsFirstPosted(Date resultsFirstPosted) {
  172. this.resultsFirstPosted = resultsFirstPosted;
  173. }
  174. public String getTitleAcronym() {
  175. return titleAcronym;
  176. }
  177. public void setTitleAcronym(String titleAcronym) {
  178. this.titleAcronym = titleAcronym;
  179. }
  180. public String getUrl() {
  181. return url;
  182. }
  183. public void setUrl(String url) {
  184. this.url = url;
  185. }
  186. public Set<Conditions> getConditionss() {
  187. return conditionss;
  188. }
  189. public void setConditionss(Set<Conditions> conditionss) {
  190. this.conditionss = conditionss;
  191. }
  192. public Set<CXCustomeDesigns> getCxCustomeDesignss() {
  193. return cxCustomeDesignss;
  194. }
  195. public void setCxCustomeDesignss(Set<CXCustomeDesigns> cxCustomeDesignss) {
  196. this.cxCustomeDesignss = cxCustomeDesignss;
  197. }
  198. public Set<CXCustomeFacilities> getCxCustomeFacilities() {
  199. return cxCustomeFacilities;
  200. }
  201. public void setCxCustomeFacilities(Set<CXCustomeFacilities> cxCustomeFacilities) {
  202. this.cxCustomeFacilities = cxCustomeFacilities;
  203. }
  204. public Set<CXCustomeInterventions> getCxCustomeInterventionss() {
  205. return cxCustomeInterventionss;
  206. }
  207. public void setCxCustomeInterventionss(Set<CXCustomeInterventions> cxCustomeInterventionss) {
  208. this.cxCustomeInterventionss = cxCustomeInterventionss;
  209. }
  210. public Set<Documents> getDocumentss() {
  211. return documentss;
  212. }
  213. public void setDocumentss(Set<Documents> documentss) {
  214. this.documentss = documentss;
  215. }
  216. public Set<IdInformation> getIdInformations() {
  217. return idInformations;
  218. }
  219. public void setIdInformations(Set<IdInformation> idInformations) {
  220. this.idInformations = idInformations;
  221. }
  222. public Set<OutcomeMeasurements> getOutcomeMeasurementss() {
  223. return outcomeMeasurementss;
  224. }
  225. public void setOutcomeMeasurementss(Set<OutcomeMeasurements> outcomeMeasurementss) {
  226. this.outcomeMeasurementss = outcomeMeasurementss;
  227. }
  228. public Set<Sponsors> getSponsorss() {
  229. return sponsorss;
  230. }
  231. public void setSponsorss(Set<Sponsors> sponsorss) {
  232. this.sponsorss = sponsorss;
  233. }
  234. public String getStudyResult() {
  235. return studyResult;
  236. }
  237. public void setStudyResult(String studyResult) {
  238. this.studyResult = studyResult;
  239. }
  240. public String getAge() {
  241. return age;
  242. }
  243. public void setAge(String age) {
  244. this.age = age;
  245. }
  246. public String getGender() {
  247. return gender;
  248. }
  249. public void setGender(String gender) {
  250. this.gender = gender;
  251. }
  252. public Date getTrialCreateDate() {
  253. return trialCreateDate;
  254. }
  255. public void setTrialCreateDate(Date trialCreateDate) {
  256. this.trialCreateDate = trialCreateDate;
  257. }
  258. public Date getUpdateDate() {
  259. return updateDate;
  260. }
  261. public void setUpdateDate(Date updateDate) {
  262. this.updateDate = updateDate;
  263. }
  264. public String getSamplingMethod() {
  265. return samplingMethod;
  266. }
  267. public void setSamplingMethod(String samplingMethod) {
  268. this.samplingMethod = samplingMethod;
  269. }
  270. public String getInclusion() {
  271. return inclusion;
  272. }
  273. public void setInclusion(String inclusion) {
  274. this.inclusion = inclusion;
  275. }
  276. public String getExclusion() {
  277. return exclusion;
  278. }
  279. public void setExclusion(String exclusion) {
  280. this.exclusion = exclusion;
  281. }
  282. public String getAcceptHealthyVol() {
  283. return acceptHealthyVol;
  284. }
  285. public void setAcceptHealthyVol(String acceptHealthyVol) {
  286. this.acceptHealthyVol = acceptHealthyVol;
  287. }
  288. public String getBriefSummary() {
  289. return briefSummary;
  290. }
  291. public void setBriefSummary(String briefSummary) {
  292. this.briefSummary = briefSummary;
  293. }
  294. public Integer getRank() {
  295. return rank;
  296. }
  297. public void setRank(Integer rank) {
  298. this.rank = rank;
  299. }
  300. public String getScope() {
  301. return scope;
  302. }
  303. public void setScope(String scope) {
  304. this.scope = scope;
  305. }
  306. }

repository:

  1. package com.jintel.ct.repository;
  2. import com.jintel.ct.entity.CXCustomeStudiesNctIdOne;
  3. import org.springframework.data.jpa.repository.EntityGraph;
  4. import org.springframework.data.jpa.repository.JpaRepository;
  5. /**
  6. * @date :2019/6/26
  7. */
  8. public interface TrialsLeftJoinByOneRepository extends JpaRepository<CXCustomeStudiesNctIdOne,Integer>{
  9. @EntityGraph(value = "CXCustomeStudiesNctIdOne.leftJoinList")
  10. CXCustomeStudiesNctIdOne findByNctId(String nctId);
  11. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/530992
推荐阅读
相关标签
  

闽ICP备14008679号