Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Getter
- @Setter
- @EqualsAndHashCode(of = "id")
- @ToString(of = "id")
- @Entity
- @Table(name = "movies_info")
- @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
- @DiscriminatorColumn(name = "dtype")
- public class MovieInfoEntity implements Serializable {
- private static final long serialVersionUID = -414335505393277302L;
- @Id
- @Basic(optional = false)
- @Column(unique = true, nullable = false, updatable = false)
- @GenericGenerator(
- name = "movieInfoSequenceGenerator", strategy = "enhanced-sequence",
- parameters = {
- @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"),
- @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
- @org.hibernate.annotations.Parameter(name = "increment_size", value = "5")
- }
- )
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "movieInfoSequenceGenerator")
- @Setter(AccessLevel.NONE)
- private Long id;
- @ManyToOne
- @JoinColumn(name = "movie_id", nullable = false)
- @NotNull
- private MovieEntity movie;
- @Basic(optional = false)
- @Column(name = "status", nullable = false)
- @Enumerated(EnumType.STRING)
- @NotNull
- private DataStatus status;
- @Basic(optional = false)
- @Column(name = "reported_for_update", nullable = false)
- private boolean reportedForUpdate;
- @Basic(optional = false)
- @Column(name = "reported_for_delete", nullable = false)
- private boolean reportedForDelete;
- @Version
- @Column(name = "entity_version", nullable = false)
- @Getter(AccessLevel.NONE)
- @Setter(AccessLevel.NONE)
- private Integer entityVersion;
- /**
- * Assign the status "WAITING" when saving a object and the status is null.
- */
- @PrePersist
- protected void onCreateMovieInfoEntity() {
- if(this.status == null) {
- this.status = DataStatus.WAITING;
- }
- }
- /**
- * Get the field of movie by the value of discrimination.
- *
- * @return Movie field
- */
- @Transient
- @Deprecated
- public MovieField getDiscriminatorValue(){
- final DiscriminatorValue val = this.getClass().getAnnotation( DiscriminatorValue.class );
- return val == null ? null : EnumUtils.getEnumFromString(MovieField.class, val.value());
- }
- }
Add Comment
Please, Sign In to add comment