Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.hibernate.annotations.GenericGenerator;
- import javax.persistence.*;
- import java.io.Serializable;
- @Table(name = "dragons")
- @Entity
- public class Smok implements Serializable{
- public enum Kolor{
- CZERWONY, CZARNY, NIEBIESKI, ZIELONY
- }
- public Smok(){
- this("smok", 0, Kolor.CZERWONY);
- }
- public Smok(String imie, int zloto, Kolor kolor){
- this.imie = imie;
- this.zloto = zloto;
- this.kolor = kolor;
- }
- private int id;
- private String imie;
- private int zloto;
- private Kolor kolor;
- private Jaskinia jaskinia;
- @Id
- @GeneratedValue(generator="increment")
- @GenericGenerator(name="increment", strategy = "increment")
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- @Column(name = "name")
- public String getImie() {
- return imie;
- }
- public void setImie(String imie) {
- this.imie = imie;
- }
- @Column(name = "gold")
- public int getZloto() {
- return zloto;
- }
- public void setZloto(int zloto) {
- this.zloto = zloto;
- }
- @Column(name = "color")
- @Enumerated(EnumType.STRING)
- public Kolor getKolor() {
- return kolor;
- }
- public void setKolor(Kolor kolor) {
- this.kolor = kolor;
- }
- @Override
- public String toString() {
- return "Smok "+imie+", posiada "+ zloto +" zΕota i jest "+kolor.toString();
- }
- @ManyToOne(optional = false, cascade = CascadeType.ALL)
- public Jaskinia getJaskinia() {
- return jaskinia;
- }
- public void setJaskinia(Jaskinia jaskinia) {
- this.jaskinia = jaskinia;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement