Advertisement
Guest User

MessageEntity

a guest
Feb 8th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1. package com.castlesbattles.model.to;
  2.  
  3. import javax.persistence.*;
  4.  
  5. /**
  6.  * Created by Reza on 1/29/2016.
  7.  */
  8. @Entity
  9. @Table(name = "message", schema = "castles_battles", catalog = "")
  10. public class MessageEntity {
  11.     private int id;
  12.     private String body;
  13.     private int coinQuantity;
  14.     private boolean claimed;
  15.     private int playerId;
  16.     PlayerEntity player;
  17.  
  18.     @Id
  19.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  20.     @Column(name = "id", nullable = false)
  21.     public int getId() {
  22.         return id;
  23.     }
  24.  
  25.     public void setId(int id) {
  26.         this.id = id;
  27.     }
  28.  
  29.     @Basic
  30.     @Column(name = "body", nullable = true, length = 2048)
  31.     public String getBody() {
  32.         return body;
  33.     }
  34.  
  35.     public void setBody(String body) {
  36.         this.body = body;
  37.     }
  38.  
  39.     @Basic
  40.     @Column(name = "coin_quantity", nullable = true)
  41.     public int getCoinQuantity() {
  42.         return coinQuantity;
  43.     }
  44.  
  45.     public void setCoinQuantity(int coinQuantity) {
  46.         this.coinQuantity = coinQuantity;
  47.     }
  48.  
  49.     @Basic
  50.     @Column(name = "claimed", nullable = true)
  51.     public boolean isClaimed() {
  52.         return claimed;
  53.     }
  54.  
  55.     public void setClaimed(boolean claimed) {
  56.         this.claimed = claimed;
  57.     }
  58.  
  59.     @Basic
  60.     @Column(name = "player_id", nullable = false)
  61.     public int getPlayerId() {
  62.         return playerId;
  63.     }
  64.  
  65.     public void setPlayerId(int playerId) {
  66.         this.playerId = playerId;
  67.     }
  68.  
  69.     @Override
  70.     public boolean equals(Object o) {
  71.         if (this == o) return true;
  72.         if (o == null || getClass() != o.getClass()) return false;
  73.  
  74.         MessageEntity that = (MessageEntity) o;
  75.  
  76.         if (id != that.id) return false;
  77.         if (coinQuantity != that.coinQuantity) return false;
  78.         if (claimed != that.claimed) return false;
  79.         if (playerId != that.playerId) return false;
  80.         if (body != null ? !body.equals(that.body) : that.body != null) return false;
  81.  
  82.         return true;
  83.     }
  84.  
  85.     @Override
  86.     public int hashCode() {
  87.         int result = id;
  88.         result = 31 * result + (body != null ? body.hashCode() : 0);
  89.         result = 31 * result + coinQuantity;
  90.         result = 31 * result + (claimed ? 1 : 0);
  91.         result = 31 * result + playerId;
  92.         return result;
  93.     }
  94.  
  95.  
  96.     @ManyToOne
  97.     @JoinColumn(name = "player_id", referencedColumnName = "id", nullable = false)
  98.     public PlayerEntity getPlayer() {
  99.         return player;
  100.     }
  101.  
  102.     public void setPlayer(PlayerEntity player) {
  103.         this.player = player;
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement