All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.gentity.demogallery.User Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version

package com.github.gentity.demogallery;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.github.gentity.ToManySide;

@Entity
@Table(name = "USER")
public class User implements Serializable
{

    @Id
    @Column(name = "ID", length = 36)
    protected String id;
    @Column(name = "USERNAME", length = 40, nullable = false)
    protected String username;
    @Column(name = "FIRST_NAME", length = 100)
    protected String firstName;
    @Column(name = "LAST_NAME", length = 100)
    protected String lastName;
    @OneToMany(mappedBy = "iconUser")
    protected List picture = new ArrayList();
    final static ToManySide , Picture> relationTo$picture = ToManySide.of((o -> o.picture), Picture.relationTo$iconUser);
    @OneToMany(mappedBy = "ownerUser")
    protected List gallery = new ArrayList();
    final static ToManySide , Gallery> relationTo$gallery = ToManySide.of((o -> o.gallery), Gallery.relationTo$ownerUser);
    @ManyToMany
    @JoinTable(name = "USER_ROLE", joinColumns = {
        @JoinColumn(name = "USER_ID", referencedColumnName = "ID")
    }, inverseJoinColumns = {
        @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID")
    })
    protected List role = new ArrayList();
    final static ToManySide , Role> relationTo$role = ToManySide.of((o -> o.role));
    @ManyToMany
    @JoinTable(name = "USER_GROUP", joinColumns = {
        @JoinColumn(name = "USER_ID", referencedColumnName = "ID")
    }, inverseJoinColumns = {
        @JoinColumn(name = "GROUP_ID", referencedColumnName = "ID")
    })
    protected List group = new ArrayList();
    final static ToManySide , Group> relationTo$group = ToManySide.of((o -> o.group));

    public static User.Builder builder() {
        return new User.Builder();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public List getPicture() {
        return (relationTo$picture.get(this));
    }

    public List getGallery() {
        return (relationTo$gallery.get(this));
    }

    public List getRole() {
        return (relationTo$role.get(this));
    }

    public List getGroup() {
        return (relationTo$group.get(this));
    }

    public static class Builder {

        private final User instance = new User();

        public User build() {
            return instance;
        }

        public User.Builder id(String id) {
            instance.id = id;
            return this;
        }

        public User.Builder username(String username) {
            instance.username = username;
            return this;
        }

        public User.Builder firstName(String firstName) {
            instance.firstName = firstName;
            return this;
        }

        public User.Builder lastName(String lastName) {
            instance.lastName = lastName;
            return this;
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy