Guest User

Untitled

a guest
Oct 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. @Entity
  2. public class Samples {
  3.  
  4. @EmbeddedId
  5. public SampleId id;
  6.  
  7.  
  8. @MapsId("samplingId")
  9. @ManyToOne(optional = false)
  10. private Samplings sampling;
  11.  
  12. @OneToOne(mappedBy = "sample", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
  13. private TestSamples testSamples;
  14. }
  15.  
  16. @Entity
  17. public class TestSamples {
  18.  
  19. @Id
  20. @SequenceGenerator(name = "test_samples_id_seq", sequenceName = "test_samples_id_seq", allocationSize = 1)
  21. @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "test_samples_id_seq")
  22. private Integer id;
  23.  
  24. @OneToOne(fetch = FetchType.LAZY)
  25. private Samples sample;
  26.  
  27. private boolean compression;
  28.  
  29. @OneToOne(mappedBy = "testSample", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
  30. private Compressions compressionTest;
  31.  
  32. ...
  33. }
  34.  
  35. select s from Samples s
  36. Join Fetch s.testSamples ts
  37. Left Join Fetch ts.compressionTest ct
  38. Join fetch s.sampling sp
  39. Left Join fetch sp.machine m
  40. Join fetch sp.product p
  41. Join fetch p.productType pt
  42. where
  43. ts.compressionTest.done=false
Add Comment
Please, Sign In to add comment