Guest User

Untitled

a guest
Jun 17th, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. package com.najdiigrac.mk.model.jpa;
  2.  
  3. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4. import com.fasterxml.jackson.annotation.JsonProperty;
  5. import com.najdiigrac.mk.model.enums.UserType;
  6. import org.hibernate.annotations.LazyCollection;
  7. import org.hibernate.annotations.LazyCollectionOption;
  8. import org.hibernate.search.annotations.*;
  9.  
  10. import javax.persistence.*;
  11. import java.util.List;
  12.  
  13. /**
  14.  * Created by bogdan on 19.4.2017.
  15.  */
  16. @Entity
  17. @Table(name = "users")
  18. public class User extends BaseEntity {
  19.  
  20.     @Field(index = org.hibernate.search.annotations.Index.YES, store = Store.NO, analyze = Analyze.YES)
  21.     @Analyzer(definition = "najdiIgracAnalyser")
  22.     @Boost(1.5f)
  23.     public String userName;
  24.  
  25.     @Enumerated(EnumType.STRING)
  26.     public UserType userType;
  27.  
  28.     /*Za da mozis da postnis user i da go zacuvas passwordot
  29.     * a ko ke zemas od baza da ne go pokazuvas
  30.     * */
  31.     @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  32.     public String password;
  33.  
  34.     public String email;
  35.  
  36.     public String telephone;
  37.  
  38.     public String description;
  39.  
  40.     @ManyToMany(fetch = FetchType.LAZY)
  41.     @JsonIgnoreProperties(
  42.             value = {"password",
  43.                     "email",
  44.                     "telephone",
  45.                     "followers",
  46.                     "userType",
  47.                     "following",
  48.                     "description"},
  49.             allowSetters = true)
  50.     // allowSetters za da mojs da deserializiras od frontend
  51.     /*@LazyCollection(LazyCollectionOption.FALSE)*/
  52.     public List<User> followers;
  53.  
  54.     @ManyToMany(fetch = FetchType.LAZY)
  55.     @JsonIgnoreProperties(
  56.                   value = {"password",
  57.                     "email",
  58.                     "telephone",
  59.                     "followers",
  60.                     "userType",
  61.                     "following",
  62.                     "description"},
  63.             allowSetters = true)
  64.     /*@LazyCollection(LazyCollectionOption.FALSE)*/
  65.     public List<User> following;
  66.  
  67.     @Override
  68.     public String toString() {
  69.         return "User{" +
  70.                 "userName='" + userName + '\'' +
  71.                 ", userType=" + userType +
  72.                 ", password='" + password + '\'' +
  73.                 ", email='" + email + '\'' +
  74.                 ", telephone='" + telephone + '\'' +
  75.                 ", followers=" + followers +
  76.                 '}';
  77.     }
  78. }
Add Comment
Please, Sign In to add comment