Skip to content
Permalink
Browse files

Added domain entities

  • Loading branch information...
borabilgin committed Jan 23, 2019
1 parent 7430562 commit 2ef285be7444856892d070645cebe40a48b72506
@@ -0,0 +1,37 @@
package com.demo.imagebrowser.domain;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "FEED")
public class Feed {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@NotNull
@Column(name = "NAME")
private String name;

@NotNull
@Column(name = "ADDRESS")
private String address;

@NotNull
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CATEGORY_ID", referencedColumnName = "ID")
private FeedCategory category;

public Feed() {
}

public Feed(Long id, String name, String address, FeedCategory category) {
this.id = id;
this.name = name;
this.address = address;
this.category = category;
}
}
@@ -0,0 +1,56 @@
package com.demo.imagebrowser.domain;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@Entity
@Table(name = "FEED_CATEGORY")
public class FeedCategory {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@NotNull
@Column(name = "NAME")
private String name;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public FeedCategory() {
}

public FeedCategory(Long id, String name) {
this.id = id;
this.name = name;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FeedCategory that = (FeedCategory) o;
return Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return Objects.hash(id);
}
}
@@ -0,0 +1,69 @@
package com.demo.imagebrowser.domain;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@Entity
@Table(name = "APP_ROLE")
public class Role {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@NotNull
@Column(name = "DESCRIPTION")
private String description;

@NotNull
@Column(name = "ROLE_NAME")
private String roleName;

public Role() {
}

public Role(Long id, String description, String roleName) {
this.id = id;
this.description = description;
this.roleName = roleName;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getRoleName() {
return roleName;
}

public void setRoleName(String roleName) {
this.roleName = roleName;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Role role = (Role) o;
return Objects.equals(id, role.id);
}

@Override
public int hashCode() {
return Objects.hash(id);
}
}
@@ -0,0 +1,87 @@
package com.demo.imagebrowser.domain;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "APP_USER")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@NotNull
@Column(name = "USERNAME")
private String username;

@NotNull
@Column(name= "PASSWORD")
private String password;

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "USER_ROLE",
joinColumns = @JoinColumn(name = "USER_ID",
referencedColumnName = "ID"),
inverseJoinColumns = @JoinColumn(name = "ROLE_ID",
referencedColumnName = "ID"))
private List<Role> roles;

public User() {
}

public User(Long id, String username, String password, List<Role> roles) {
this.id = id;
this.username = username;
this.password = password;
this.roles = roles;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public List<Role> getRoles() {
return roles;
}

public void setRoles(List<Role> roles) {
this.roles = roles;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(id, user.id);
}

@Override
public int hashCode() {
return Objects.hash(id);
}
}

0 comments on commit 2ef285b

Please sign in to comment.
You can’t perform that action at this time.