Guest User

Untitled

a guest
Dec 8th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. @Entity //ОСНОВНАЯ сущность
  2. @Table(name = "data_collection")
  3. public class DataCollectionEntity {
  4.     @Id
  5.     @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "data_collection_gen")
  6.     @SequenceGenerator(name = "data_collection_gen", sequenceName = "data_collection_sequence", allocationSize = 1)
  7.     private Long id;
  8.  
  9.  
  10.     @Enumerated(EnumType.STRING)
  11.     private DataCollectionType type;
  12.     @Column(insertable = false)
  13.     private Date modifiedOn;
  14.  
  15.     @OneToOne(fetch = FetchType.LAZY)
  16.     @JoinColumn(name = "template_id", referencedColumnName = "id")
  17.     private TemplateEntity template;
  18.  
  19.     @OneToMany(
  20.             mappedBy = "data_collection",
  21.             cascade = CascadeType.ALL,
  22.             orphanRemoval = true
  23.     )
  24.     @OrderBy("date DESC")
  25.     private Collection<DataCollectionLogEntity> dataCollectionLog;
  26.  
  27. //логи основной сущности
  28. @Entity
  29. @Table(name = "data_collection")
  30. public class DataCollectionEntity {
  31.     @Id
  32.     @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "data_collection_gen")
  33.     @SequenceGenerator(name = "data_collection_gen", sequenceName = "data_collection_sequence", allocationSize = 1)
  34.     private Long id;
  35.  
  36.     private String name;
  37.  
  38.     private byte[] data;
  39.  
  40.     private String fileName;
  41.  
  42.     private String description;
  43.  
  44.     @Enumerated(EnumType.STRING)
  45.     private DataCollectionType type;
  46.     @Column(insertable = false)
  47.     private Date modifiedOn;
  48.  
  49.     @ManyToOne(fetch = FetchType.LAZY)
  50.     @JoinColumn(name = " author_id")
  51.     private UserEntity author;
  52.  
  53.     @OneToOne(fetch = FetchType.LAZY)
  54.     @JoinColumn(name = "template_id", referencedColumnName = "id")
  55.     private TemplateEntity template;
  56.  
  57.     @OneToMany(
  58.             mappedBy = "data_collection",
  59.             cascade = CascadeType.ALL,
  60.             orphanRemoval = true
  61.     )
  62.     @OrderBy("date DESC")
  63.     private Collection<DataCollectionLogEntity> dataCollectionLog;
Advertisement
Add Comment
Please, Sign In to add comment