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

com.github.gentity.test.test3.User Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version

package com.github.gentity.test.test3;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.github.gentity.ToOneSide;

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

    @Id
    @Column(name = "ID")
    protected Integer id;
    @Column(name = "NAME", length = 100)
    protected String name;
    @ManyToOne
    @JoinColumn(name = "CUSTOMER_ID")
    protected Customer customer;
    final static ToOneSide relationTo$customer = ToOneSide.of((o -> o.customer), ((o,m) -> o.customer = m), Customer.relationTo$user);

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

    public Integer getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Customer getCustomer() {
        return (relationTo$customer.get(this));
    }

    public void setCustomer(Customer customer) {
        relationTo$customer.set(this, customer);
    }

    public static class Builder {

        private final User instance = new User();

        public User build() {
            return instance;
        }

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

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

        public User.Builder customer(Customer customer) {
            instance.customer = customer;
            return this;
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy