root / middleware / src / com / gonnatrak / middleware / entity / Group.java @ 1

View | Annotate | Download

1
/**
2
 * Created by Andrey Khalzov
3
 * 11.07.2008 3:07:58
4
 */
5
package com.gonnatrak.middleware.entity;
6
7
import org.jetbrains.annotations.NotNull;
8
9
import javax.persistence.*;
10
import java.util.Collections;
11
import java.util.Set;
12
13
@Entity
14
@Table(name = Group.TABLE_NAME)
15
public class Group extends TicketOwner {
16
    public static final String TABLE_NAME = "g_group";
17
18
    @ManyToMany(targetEntity = User.class)
19
    @JoinTable(name = User.USER_GROUP_TABLE_NAME,
20
               joinColumns = {@JoinColumn(name = User.GROUP)},
21
               inverseJoinColumns = {@JoinColumn(name = User.USER)},
22
               uniqueConstraints = {
23
                   @UniqueConstraint(columnNames = {User.GROUP, User.USER}),
24
                   @UniqueConstraint(columnNames = {User.USER, User.GROUP})
25
               }
26
    )
27
    private Set<User> users;
28
29
    @NotNull
30
    public Set<User> getUsers() {
31
        if (users == null) {
32
            Collections.emptySet();
33
        }
34
        return users;
35
    }
36
37
    public void setUsers(Set<User> users) {
38
        this.users = users;
39
    }
40
}