I am trying to save entity with relational other entity.
Here's my Entities
#MappedSuperclass
public abstract class BaseEntity {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
BaseEntity() {
}
protected BaseEntity(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BaseEntity that = (BaseEntity) o;
return id.equals(that.id);
}
#Override
public int hashCode() {
return Objects.hash(id);
}
}
#Entity
#Inheritance(strategy = InheritanceType.SINGLE_TABLE)
#DiscriminatorColumn(name = "auth_type")
public abstract class BlogUser extends BaseEntity {
#ManyToOne
#JoinColumn(name = "user_id", nullable = false, updatable = false)
private User user;
#ManyToOne
#JoinColumn(name = "blog_id", nullable = false, updatable = false)
private Blog blog;
BlogUser() {
}
protected BlogUser(User user, Blog blog) {
this.user = user;
this.blog = blog;
}
public User getUser() {
return user;
}
public Blog getBlog() {
return blog;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BlogUser)) return false;
BlogUser blogUser = (BlogUser) o;
return user.equals(blogUser.getUser()) && blog.equals(blogUser.getBlog());
}
#Override
public int hashCode() {
return Objects.hash(user, blog);
}
}
#Entity
#DiscriminatorValue("ADMIN")
public class BlogAdmin extends BlogUser {
public BlogAdmin(User user, Blog blog) {
super(user, blog);
}
}
#Entity
#DiscriminatorValue("INVITED")
public class BlogInvitedUser extends BlogUser {
public BlogInvitedUser(User user, Blog blog) {
super(user, blog);
}
}
#Entity
public class Blog extends BaseEntity {
//fields
#OneToMany(mappedBy = "blog", cascade = CascadeType.PERSIST)
private Set<BlogUser> blogUsers = new HashSet<>();
Blog() {
}
public Blog(String name, String introduce) {
this.name = name;
this.introduce = introduce;
}
//other field's getters
public Set<BlogUser> getBlogUsers() {
return blogUsers;
}
public void addBlogUser(BlogUser blogUser) {
if (blogUsers.contains(blogUser)) { // This is not working
throw new DataIntegrityViolationException("blog's users is duplicated");
}
blogUsers.add(blogUser);
}
}
When Saving Blog Entity with blog user that BlogUser' child entity, Blog's addBlogUser method is not working!
I know Set works by hashCode method.
So, I override BlogUser entity's hashCode and equals method.
But Testing result is weird.
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = ApplicationConfiguration.class, loader = AnnotationConfigContextLoader.class)
public class BlogUserTest {
#Autowired
private UserDao userDao;
#Autowired
private BlogDao blogDao;
#Test
#Transactional
public void WhenAddBlogUsers_GivenDifferntTypeSameUserAndBlogAfterPersistBlog_ThrowDataIntegrityViolationException() {
User user = new User("name", "nick", "email", null);
userDao.save(user);
Blog blog = new Blog("test", null);
BlogUser admin = new BlogAdmin(user, blog);
blog.addBlogUser(admin);
blogDao.save(blog);
System.out.println(blog.getBlogUsers().iterator().next().hashCode() == new BlogInvitedUser(user, blog).hashCode()); // true
System.out.println(blog.getBlogUsers().contains(new BlogInvitedUser(user, blog))); // false
}
}
In fact, while testing, I knew that It works if EntityManager persist that.
I wonder what is happening internally.
Any answer is welcome.
Related
I have an issue with this error, I want to delete the specific data from join table role_access, but delete random data inside the table. I applied many to many mapping which consist of role, access and linked table role_access. i have tried remove() using iterator but doesn't worked.Anyone please help me, thank you.
Here I share my code:
Role.java
#ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH, CascadeType.MERGE, CascadeType.REMOVE,
CascadeType.PERSIST })
#JoinTable(name = "role_access", joinColumns = {
#JoinColumn(name = "roleId", referencedColumnName = "rid") }, inverseJoinColumns = {
#JoinColumn(name = "accessId", referencedColumnName = "id") })
private List<Access> access = new ArrayList<>();
RoleController.java
#PostMapping("/delete/access/{roleName}")
public ResponseEntity<Object> deleteRoleAccess(#PathVariable String roleName) {
return roleService.deleteRoleToAccess(roleName);
}
RoleRepository.java
#Repository
public interface RoleRepository extends JpaRepository<Role, Long> {
Optional<Role> findByRoleName(String roleName);
Optional<Role> findByRid(Long rid); }
RoleService.java
public ResponseEntity<Object> deleteRoleToAccess(String roleName) {
if (roleRepository.findByRoleName(roleName).isPresent()) {
Role r = roleRepository.findByRoleName(roleName).get();
for (int i = 0; i < r.getAccess().size(); i++) {
if (accessRepository.findByAccName(r.getAccess().get(i).getAccName()).isPresent()) {
Access access = r.getAccess().get(i);
delAccess(r, access.getAccName());
} else
return ResponseEntity.unprocessableEntity().body("Role name not found");
}
roleRepository.save(r);
}
return ResponseEntity.ok("access is successfully delete");
}
public void delAccess(Role role, String accName) {
Optional<Access> aOpt = accessRepository.findByAccName(accName);
if (!aOpt.isPresent()) {
throw new CustEmailNotFoundexception("Access name cannot be null");
}
if (aOpt.isPresent() && aOpt.equals(aOpt)) {
role.getAccess().remove(aOpt.get());
}}
I think you are over complicating things a bit with your service which can be simplified to something like this
#Transactional
public ResponseEntity<Object> deleteRoleToAccess(String roleName) {
Optional<Role> optionalRole = roleRepository.findByRoleName(roleName);
if (!optionalRole.isPresent()) {
return ResponseEntity.unprocessableEntity().body("Role name not found");
}
Role role = optionalRole.get();
List<Access> removeList = new ArrayList<>(role.getAccesses());
for (Access access : removeList) {
role.removeAccess(access);
}
return ResponseEntity.ok("access is successfully delete");
}
But to do so you need to make changes to your entities
// Role
#Entity
public class Role {
#Id
#Column(name = "rid")
private Long rid;
private String roleName;
#ManyToMany(
fetch = FetchType.EAGER,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
}
)
#JoinTable(name = "role_access",
joinColumns = #JoinColumn(name = "roleId"),
inverseJoinColumns = #JoinColumn(name = "rid")
)
private List<Access> accesses = new ArrayList<>();
public Long getRid() {
return rid;
}
public void setRid(Long rid) {
this.rid = rid;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public List<Access> getAccesses() {
return accesses;
}
public void addAccess(Access access) {
accesses.add(access);
access.getRoles().add(this);
}
public void removeAccess(Access access) {
accesses.remove(access);
access.getRoles().remove(this);
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Role role = (Role) o;
return getRid().equals(role.getRid());
}
#Override
public int hashCode() {
return Objects.hash(getRid());
}
}
// Access
#Entity
public class Access {
#Id
#Column(name = "id")
private Long accessId;
private String accName;
#ManyToMany(mappedBy = "accesses")
private List<Role> roles = new ArrayList<>();
public Long getAccessId() {
return accessId;
}
public void setAccessId(Long accessId) {
this.accessId = accessId;
}
public String getAccName() {
return accName;
}
public void setAccName(String accName) {
this.accName = accName;
}
public List<Role> getRoles() {
return roles;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Access access = (Access) o;
return getAccessId().equals(access.getAccessId());
}
#Override
public int hashCode() {
return Objects.hash(getAccessId());
}
}
Environment:
javaee 7
java 8
jpa 2
I got the error EntityNotFoundException when I make a query of Moviment and automatically tries to load the associated Espai after I have modifed Espai class to separate id and version in a separate class with the annotation #MappedSuperclass.
I can suspect that it is something related with equals() and hashCode() methods but I have not been able to figure out the problem.
Espai that works fine
#Entity
#Table(name = "a_espai")
public class Espai implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nom;
private Integer version;
#ManyToOne
#JoinColumn(name = "idServei", referencedColumnName = "id")
private Servei servei;
...
#Override
public int hashCode() {
int hash = servei == null ? 1 : servei.getId();
return hash;
}
#Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Espai)) {
return false;
}
Espai other = (Espai) obj;
return id != null && id.equals(other.getId());
}
}
Espai after change that provokes the error
#Entity
#Table(name = "a_espai")
public class Espai extends BaseEntity implements Serializable {
private String nom;
#ManyToOne
#JoinColumn(name = "idServei", referencedColumnName = "id")
private Servei servei;
#Override
public int hashCode() {
int hash = 0;
if (servei == null) {
return hash;
} else {
return servei.getId();
}
}
#Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Espai)) {
return false;
}
Espai other = (Espai) obj;
return getId() != null && getId().equals(other.getId());
}
}
Moviment class where Espai gets the error on eager loading
#Entity
#Table(name = "t_moviment")
public class Moviment extends BaseEntity implements Serializable {
private LocalDate dataInici;
private LocalDate dataFi;
private String observacio;
#ManyToOne
#Basic(optional = false)
#JoinColumn(name = "idEspai", referencedColumnName = "id")
private Espai espai;
...
}
**Espai before change that provokes the error**
#MappedSuperclass
public class BaseEntity {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
#Version
protected Integer version;
public Integer getId() {
return id;
}
}
When a parent entity is persisted/merged via saveAndFlush, it tries to insert a new record for the child entity instead of finding/merging the existing record. This causes a SQLIntegrityConstraintViolationException error. I have also tried pulling the existing entity directly via the DAO, setting that to be the field in the parent entity, and then saving and flushing, and it still tries to insert a new record for the child entity field.
Any help is greatly appreciated!
Child Entity
#Entity
#Table(name = "DROPDOWN_TYPE", uniqueConstraints = {
#UniqueConstraint(columnNames = { "DROPDOWN_TYPE_TXT" }, name = "DROPDOWN_TYPE_TXT_UK") })
public class DropdownType {
#Id
#Column(name = "DROPDOWN_TYPE_TXT")
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DropdownType that = (DropdownType) o;
return text.equals(that.text);
}
#Override
public int hashCode() {
return text.hashCode();
}
}
Parent Entity
#Entity
#Table(name = "DROPDOWN", uniqueConstraints = {
#UniqueConstraint(columnNames = { "DROPDOWN_TXT", "DROPDOWN_TYPE_TXT" }, name = "DROPDOWN_UK") })
#JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Dropdown {
#Id
#GeneratedValue(strategy = GenerationType.AUTO, generator = "DROPDOWN_OPTION_ID_GENERATOR")
#SequenceGenerator(allocationSize = 1, name = "DROPDOWN_OPTION_ID_GENERATOR", sequenceName = "DROPDOWN_OPTION_ID_SQ")
#Column(name = "DROPDOWN_OPTION_ID")
private Long id;
#ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST })
#JoinColumn(name = "DROPDOWN_TYPE_TXT", foreignKey = #ForeignKey(name = "DROPDOWN_TYPE_TXT_FK"))
private DropdownType dropdownType;
#Column(name = "DROPDOWN_TXT")
private String text;
#Column(name = "ACTIVE_FLG")
private Boolean active;
#Column(name = "LEGACY_FLG")
private Boolean legacy;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public DropdownType getDropdownType() {
return dropdownType;
}
public void setDropdownType(DropdownType dropdownType) {
this.dropdownType = dropdownType;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Boolean isActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
public Boolean isLegacy() {
return legacy;
}
public void setLegacy(Boolean legacy) {
this.legacy = legacy;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Dropdown dropdown = (Dropdown) o;
return dropdownType.equals(dropdown.dropdownType) && text.equals(dropdown.text);
}
#Override
public int hashCode() {
int result = dropdownType != null ? dropdownType.hashCode() : 0;
result = 31 * result + (text != null ? text.hashCode() : 0);
return result;
}
}
If you are using hibernate as your JPA provider, be careful when you override equals and hashcode -- see this post
It may be, that your JPA provider does not consider your entities to be equal as loaded entities can be some CGLIB proxies in reality (probably better to use instanceof than to compare classes).
I have two fields that should appear in each table. So I wanted to create an entity that will hold these fields and the rest of my entities inherited these fields
But when I run the query I get the error - org.hibernate.QueryException: could not resolve property: active of: com.db.tables.PersonTable
what i'm doing wrong?
Base class all entities should inherit these fields
#XmlRootElement
#Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class BaseTable implements Serializable
{
private static final long serialVersionUID = 1L;
#Column(name = "Updated")
#JsonProperty
#NotNull
protected Timestamp updated;
#Column(name = "Active")
#JsonProperty
#NotNull
protected byte active;
public BaseTable ()
{
active = (byte)1;
updated = DbUtils.getCurrentTimeStamp();
}
public byte getActive()
{
return active;
}
public void setActive(byte active)
{
this.active = active;
}
public Timestamp getUpdated()
{
return updated;
}
public void setUpdated(Timestamp updated)
{
this.updated = updated;
}
#Override
public String toString()
{
return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
}
#Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + active;
result = prime * result + ((updated == null) ? 0 : updated.hashCode());
return result;
}
#Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
BaseTable other = (BaseTable) obj;
if (active != other.active) return false;
if (updated == null)
{
if (other.updated != null) return false;
}
else if (!updated.equals(other.updated)) return false;
return true;
}
}
A class that inherits
#Entity(name = "Persons")
#Table(name = "Persons")
public class PersonTable extends BaseTable implements Serializable
{
private static final long serialVersionUID = -5793514680136648542L;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "PersonId")
private short personId;
#OneToOne(cascade = CascadeType.ALL)
#JoinColumn(name="personId")
PortalUserTable portalUser;
//getters&settersand more fields
}
one more class that inherits
#Entity(name = "PortalUser")
#Table(name = "PortalUser")
public class PortalUserTable extends BaseTable implements Serializable
{
private static final long serialVersionUID = -5793514680136648542L;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "PersonId")
private short personId;
#OneToOne
(mappedBy = "portalUser")
PersonTable person;
//getters&settersand more fields
}
the query
public ObjectDaoResponse getAllTigrisUsers() throws JsonProcessingException
{
try
{
Query q = sessionFactory.getCurrentSession().createQuery("SELECT new com.db.queries.users.User( u.portalUserId ,p.personName) FROM PortalUsers u INNER JOIN u.person p WHERE portalUserId = p.personId AND p.active = 1 AND u.active = 1");
List<TigrisUser> l = q.list();
return ObjectDaoResponse.getAnOkResponse(l);
}
catch(Exception e)
{
System.out.println(e);
return ObjectDaoResponse.getGeneralFailureResponse();
}
}
#MappedSuperclass
public class BaseTable ...
I would suggest to change naming convention Base(Table) -> Base(Entity). Do the same for all entity classes.
You should take care of inheritance strategy - https://en.wikibooks.org/wiki/Java_Persistence/Inheritance
I have three entities: Account, AccountAttribut and Attribut. Account and Attribut are associated via AccountAttribut in a many-to-many relationship like it is described here (1). AccountAttribut is a join table entity that holds an additional attribute.
I try to build a HQL string that delivers all Accounts with the "wert"-property "John" in AccountAttribut and the name-property "FirstName" in Attribut.
I dont find the right HQL string. Can you help me out?
(1): http://giannigar.wordpress.com/2009/09/04/mapping-a-many-to-many-join-table-with-extra-column-using-jpa/ "Mapping a many-to-many join table with extra column using JPA"
I tried this query:
List<Account> queried_accounts = HibernateUtils.queryList(
session.createQuery(""
+ "from Account as acc"
+ " full join acc.accountAttributes as accAtt"
+ " inner join accAtt.aa_pk.attribut as attr"
+ " where attr.name='FirstName' and accAtt.wert='John'")
);
and i get this error message:
ERROR: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'full outer join account_attribut accountatt1_ on
account0_.account_id=accountatt' at line 1
UPDATE:
I changed the query to:
List<Account> queried_accounts = HibernateUtils.queryList(
session.createQuery(""
+ "from Account as acc"
+ " inner join acc.accountAttributes as accAtt"
+ " inner join accAtt.aa_pk.attribut as attr"
+ " where attr.name='FirstName' and accAtt.wert='John'")
);
This seems to work.
But now i got a new Problem: queried_accounts does not seem to be a List of Accounts. If i get an object out of queried_accounts and try to apply account methods on it, i get an Exception at runtime.
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
com.computacenter.qct.pojos.Account
These are relevant code extracts:
Account:
#Entity
#Table(name = "account")
public class Account {
private Long accountId;
private List<AccountAttribut> accountAttributes = new LinkedList<AccountAttribut>();
private Person person;
private Zielsystem zielsystem;
public Account() {
}
#Id
#GeneratedValue
#Column(name = "account_id", nullable = false)
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "aa_pk.account", cascade = {
CascadeType.PERSIST, CascadeType.MERGE })
#Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
public List<AccountAttribut> getAccountAttributes() {
return accountAttributes;
}
public void setAccountAttributes(List<AccountAttribut> accountAttribute) {
this.accountAttributes = accountAttribute;
}
#ManyToOne
#JoinColumn(name = "person_id")
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
#ManyToOne
#JoinColumn(name="zielsystem_id")
public Zielsystem getZielsystem() {
return zielsystem;
}
public void setZielsystem(Zielsystem zielsystem) {
this.zielsystem = zielsystem;
}
}
AccountAttribut:
#Entity
#Table(name="account_attribut")
#AssociationOverrides({
#AssociationOverride(name="aa_pk.account", joinColumns = #JoinColumn(name="account_id")),
#AssociationOverride(name="aa_pk.attribut", joinColumns = #JoinColumn(name="attribut_id"))
})
public class AccountAttribut {}
private AccountAttributPk aa_pk = new AccountAttributPk();
#Column(name="wert")
private String wert;
#EmbeddedId
public AccountAttributPk getAa_pk() {
return aa_pk;
}
public void setAa_pk(AccountAttributPk aa_pk) {
this.aa_pk = aa_pk;
}
#Transient
public Account getAccount() {
return getAa_pk().getAccount();
}
public void setAccount(Account account) {
getAa_pk().setAccount(account);
}
#Transient
public Attribut getAttribut() {
return getAa_pk().getAttribut();
}
public void setAttribut(Attribut attribut) {
getAa_pk().setAttribut(attribut);
}
public String getWert() {
return wert;
}
public void setWert(String wert) {
this.wert = wert;
}
public boolean equals(Object o) {
if (this== o) return true;
if (o ==null|| getClass() != o.getClass()) return false;
AccountAttribut that = (AccountAttribut) o;
if (getAa_pk() !=null?!getAa_pk().equals(that.getAa_pk()) : that.getAa_pk() !=null) return false;
return true;
}
public int hashCode() {
return (getAa_pk() !=null? getAa_pk().hashCode() : 0);
}
}
AccountAttributPk:
public class AccountAttributPk implements Serializable {
private static final long serialVersionUID = -1551814445010872872L;
private Account account;
private Attribut attribut;
#ManyToOne
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
#ManyToOne
public Attribut getAttribut() {
return attribut;
}
public void setAttribut(Attribut attribut) {
this.attribut = attribut;
}
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
AccountAttributPk that = (AccountAttributPk) o;
if (account != null ? !account.equals(that.account) : that.account != null)
return false;
if (attribut != null ? !attribut.equals(that.attribut)
: that.attribut != null)
return false;
return true;
}
public int hashCode() {
int result;
result = (account != null ? account.hashCode() : 0);
result = 31 * result + (attribut != null ? attribut.hashCode() : 0);
return result;
}
}
Attribut
#Entity
#Table(name="Attribut")
public class Attribut {
private Long attributId;
private String name;
private List<PersonAttribut> personenAttribute = new LinkedList<PersonAttribut>();
private List<AccountAttribut> accountAttribute = new LinkedList<AccountAttribut>();
private List<BerechtigungsobjektAttribut> berechtigungsobjektAttribute = new LinkedList<BerechtigungsobjektAttribut>();
public Attribut() {}
public Attribut(String name) {
this.name = name;
}
#Id
#GenericGenerator(name="generator", strategy="increment")
#GeneratedValue(generator="generator")
#Column(name="attribut_id", nullable=false)
public Long getAttributId() {
return attributId;
}
public void setAttributId(Long attributId) {
this.attributId = attributId;
}
#Column(name="name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "pa_pk.attribut", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
#Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
public List<PersonAttribut> getPersonenAttribute() {
return personenAttribute;
}
public void setPersonenAttribute(List<PersonAttribut> personenAttribute) {
this.personenAttribute = personenAttribute;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "aa_pk.attribut", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
#Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
public List<AccountAttribut> getAccountAttribute() {
return accountAttribute;
}
public void setAccountAttribute(List<AccountAttribut> accountAttribute) {
this.accountAttribute = accountAttribute;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "ba_pk.attribut", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
#Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
public List<BerechtigungsobjektAttribut> getBerechtigungsobjektAttribute() {
return berechtigungsobjektAttribute;
}
public void setBerechtigungsobjektAttribute(
List<BerechtigungsobjektAttribut> berechtigungsobjektAttribute) {
this.berechtigungsobjektAttribute = berechtigungsobjektAttribute;
}
#Override
public String toString() {
return name;
}
#Override
public boolean equals(Object other) {
if (other == null)
return false;
if (this == other)
return true;
if (this.getClass() != other.getClass())
return false;
final Attribut otherAccount = (Attribut) other;
return EqualsUtils.nullSafeEquals(this.getName(), otherAccount.getName());
}
#Override
public int hashCode() {
final int PRIME = 42;
return this.name.hashCode() * PRIME;
}
}