/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.luckycode.projetawebservice;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author michael
 */
@Entity
@Table(name = "usergroup")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Usergroup.findAll", query = "SELECT u FROM Usergroup u"),
    @NamedQuery(name = "Usergroup.findByUsergroupId", query = "SELECT u FROM Usergroup u WHERE u.usergroupId = :usergroupId"),
    @NamedQuery(name = "Usergroup.findByCode", query = "SELECT u FROM Usergroup u WHERE u.code = :code")})
public class Usergroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "usergroup_id")
    private Integer usergroupId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "code")
    private String code;
    @JoinTable(name = "user_usergroup", joinColumns = {
        @JoinColumn(name = "usergroup_id", referencedColumnName = "usergroup_id")}, inverseJoinColumns = {
        @JoinColumn(name = "user_id", referencedColumnName = "user_id")})
    @ManyToMany
    private Collection<User> userCollection;
    @ManyToMany(mappedBy = "usergroupCollection")
    private Collection<Project> projectCollection;

    public Usergroup() {
    }

    public Usergroup(Integer usergroupId) {
        this.usergroupId = usergroupId;
    }

    public Usergroup(Integer usergroupId, String code) {
        this.usergroupId = usergroupId;
        this.code = code;
    }

    public Integer getUsergroupId() {
        return usergroupId;
    }

    public void setUsergroupId(Integer usergroupId) {
        this.usergroupId = usergroupId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @XmlTransient
    public Collection<User> getUserCollection() {
        return userCollection;
    }

    public void setUserCollection(Collection<User> userCollection) {
        this.userCollection = userCollection;
    }

    @XmlTransient
    public Collection<Project> getProjectCollection() {
        return projectCollection;
    }

    public void setProjectCollection(Collection<Project> projectCollection) {
        this.projectCollection = projectCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usergroupId != null ? usergroupId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Usergroup)) {
            return false;
        }
        Usergroup other = (Usergroup) object;
        if ((this.usergroupId == null && other.usergroupId != null) || (this.usergroupId != null && !this.usergroupId.equals(other.usergroupId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "be.luckycode.projetawebservice.Usergroup[ usergroupId=" + usergroupId + " ]";
    }
    
}

@@ -1213,16 +1213,131 @@
  :code%22)
+,%0A    @NamedQuery(name = %22Usergroup.findByComment%22, query = %22SELECT u FROM Usergroup u WHERE u.comment = :comment%22)
 %7D)%0Apubli
@@ -1726,24 +1726,103 @@
 tring code;%0A
+    @Size(max = 255)%0A    @Column(name = %22comment%22)%0A    private String comment;%0A
     @JoinTab
@@ -2757,32 +2757,185 @@
 e = code;%0A    %7D%0A
+    %0A    public String getComment() %7B%0A        return comment;%0A    %7D%0A%0A    public void setComment(String comment) %7B%0A        this.comment = comment;%0A    %7D%0A%0A
 %0A    @XmlTransie

Add comment property to Usergroup class to reflect database changes.