Guest User

MovieInfoEntity

a guest
Jun 3rd, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. @Getter
  2. @Setter
  3. @EqualsAndHashCode(of = "id")
  4. @ToString(of = "id")
  5. @Entity
  6. @Table(name = "movies_info")
  7. @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  8. @DiscriminatorColumn(name = "dtype")
  9. public class MovieInfoEntity implements Serializable {
  10.  
  11.     private static final long serialVersionUID = -414335505393277302L;
  12.  
  13.     @Id
  14.     @Basic(optional = false)
  15.     @Column(unique = true, nullable = false, updatable = false)
  16.     @GenericGenerator(
  17.             name = "movieInfoSequenceGenerator", strategy = "enhanced-sequence",
  18.             parameters = {
  19.                     @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"),
  20.                     @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
  21.                     @org.hibernate.annotations.Parameter(name = "increment_size", value = "5")
  22.             }
  23.     )
  24.     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "movieInfoSequenceGenerator")
  25.     @Setter(AccessLevel.NONE)
  26.     private Long id;
  27.  
  28.     @ManyToOne
  29.     @JoinColumn(name = "movie_id", nullable = false)
  30.     @NotNull
  31.     private MovieEntity movie;
  32.  
  33.     @Basic(optional = false)
  34.     @Column(name = "status", nullable = false)
  35.     @Enumerated(EnumType.STRING)
  36.     @NotNull
  37.     private DataStatus status;
  38.  
  39.     @Basic(optional = false)
  40.     @Column(name = "reported_for_update", nullable = false)
  41.     private boolean reportedForUpdate;
  42.  
  43.     @Basic(optional = false)
  44.     @Column(name = "reported_for_delete", nullable = false)
  45.     private boolean reportedForDelete;
  46.  
  47.     @Version
  48.     @Column(name = "entity_version", nullable = false)
  49.     @Getter(AccessLevel.NONE)
  50.     @Setter(AccessLevel.NONE)
  51.     private Integer entityVersion;
  52.  
  53.     /**
  54.      * Assign the status "WAITING" when saving a object and the status is null.
  55.      */
  56.     @PrePersist
  57.     protected void onCreateMovieInfoEntity() {
  58.         if(this.status == null) {
  59.             this.status = DataStatus.WAITING;
  60.         }
  61.     }
  62.  
  63.     /**
  64.      * Get the field of movie by the value of discrimination.
  65.      *
  66.      * @return Movie field
  67.      */
  68.     @Transient
  69.     @Deprecated
  70.     public MovieField getDiscriminatorValue(){
  71.         final DiscriminatorValue val = this.getClass().getAnnotation( DiscriminatorValue.class );
  72.  
  73.         return val == null ? null : EnumUtils.getEnumFromString(MovieField.class, val.value());
  74.     }
  75. }
Add Comment
Please, Sign In to add comment