1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| package organization.basis.domain.model.security.groups;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Index;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
/**
*
* @author Khaled.Noordin
*/
@Entity
@Table(name = GroupAuthorities.PROP_ENTITY_TABLE)
@Access(value = AccessType.PROPERTY)
@IdClass(value = GroupAuthoritiesId.class)
@XmlRootElement
@NamedNativeQuery(name = GroupAuthorities.NATIVENAMEDQUERY_FIXPK,
query = "ALTER TABLE "
+ GroupAuthorities.PROP_ENTITY_TABLE
+ " DROP PRIMARY KEY ;"
+ "ALTER TABLE "
+ GroupAuthorities.PROP_ENTITY_TABLE
+ " ADD PRIMARY KEY ("
+ GroupAuthorities.PROP_GROUPS
+ ","
+ GroupAuthorities.PROP_AUTHORITY + ");")
@NamedQueries({
@NamedQuery(name = GroupAuthorities.NAMEDQUERY_FINDALL,
query = "SELECT g FROM GroupAuthorities g"),
@NamedQuery(name = GroupAuthorities.NAMEDQUERY_FINDBYGROUPS,
query = "SELECT g FROM GroupAuthorities g WHERE g.groups = :groups"),
@NamedQuery(name = GroupAuthorities.NAMEDQUERY_FINDBYAUTHORITY,
query = "SELECT g FROM GroupAuthorities g WHERE g.authority = :authority")
})
public class GroupAuthorities implements Serializable {
private static final long serialVersionUID = 3665548523131336391L;
public static final String PROP_ENTITY_TABLE = "group_authorities";
public static final String PROP_AUTHORITY = "authority";
public static final String PROP_GROUPS = "group_id";
public static final String NAMEDQUERY_FINDALL =
"GroupAuthorities.findAll";
public static final String NAMEDQUERY_FINDBYGROUPS =
"GroupAuthorities.findByGroups";
public static final String NAMEDQUERY_FINDBYAUTHORITY =
"GroupAuthorities.findByAuthority";
public static final String NATIVENAMEDQUERY_FIXPK =
"GroupAuthorities.fixPK";
private Groups groups;
private String authority;
public GroupAuthorities() {
this.groups = null;
this.authority = null;
}
public GroupAuthorities(
Groups groups,
String authority) {
this();
this.groups = groups;
this.authority = authority;
}
public GroupAuthorities(
GroupAuthoritiesId groupAuthoritiesId) {
this(groupAuthoritiesId.getGroups(),
groupAuthoritiesId.getAuthority());
}
@Id
@JoinColumn(name = PROP_GROUPS,
referencedColumnName = Groups.PROP_ID,
insertable = false,
updatable = false)
@ManyToOne(optional = false)
public Groups getGroups() {
return groups;
}
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = PROP_AUTHORITY)
@Index(name = "idx_group_auth_autority")
public String getAuthority() {
return authority;
}
public void setGroups(Groups groups) {
this.groups = groups;
}
public void setAuthority(String authority) {
this.authority = authority;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return ( !( object instanceof GroupAuthorities )
|| object == null ) ? false
: EqualsBuilder.reflectionEquals(
this,
object);
}
} |
Partager