com.brihaspathee.zeus.domain.security.Role Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tp-service Show documentation
Show all versions of tp-service Show documentation
Service that contains all Trading Partner Information
The newest version!
package com.brihaspathee.zeus.domain.security;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Table;
import lombok.*;
import org.hibernate.annotations.*;
import jakarta.persistence.*;
import java.sql.Types;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
/**
* Created in Intellij IDEA
* User: Balaji Varadharajan
* Date: 21, January 2022
* Time: 9:09 AM
* Project: Zeus
* Package Name: com.zeus.domain.entity
* To change this template use File | Settings | File and Code Template
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "role")
public class Role {
@Id
@GeneratedValue(generator = "UUID")
@JdbcTypeCode(Types.LONGVARCHAR)
@GenericGenerator(name="UUID", strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "role_id", length = 36, columnDefinition = "varchar", updatable = false, nullable = false)
private UUID roleId;
@Column(name = "role_name", nullable = false, length = 100)
private String roleName;
@ManyToMany(mappedBy = "roles")
private Set users;
@Singular
@ManyToMany(cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
@JoinTable(name = "ROLE_AUTHORITY",
joinColumns = {@JoinColumn(name = "ROLE_ID")},
inverseJoinColumns = {@JoinColumn(name = "AUTHORITY_ID")})
private Set authorities;
@CreationTimestamp
@Column(name = "created_date", nullable = false)
private LocalDateTime createdDate;
@UpdateTimestamp
@Column(name = "updated_date", nullable = false)
private LocalDateTime updatedDate;
@Override
public String toString() {
return "Role{" +
"roleId=" + roleId +
", 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 roleId.equals(role.roleId);
}
@Override
public int hashCode() {
return Objects.hash(roleId);
}
}