BioReference.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04.
//
package org.andromda.demo.ejb3.bio;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
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.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * TODO: Model Documentation for org.andromda.demo.ejb3.bio.BioReference
 * </p>
 *
 * Autogenerated POJO EJB class for BioReference containing the
 * bulk of the entity implementation.
 *
 * This is autogenerated by AndroMDA using the EJB3
 * cartridge.
 *
 * DO NOT MODIFY this class.
 */
@Entity
@Table(name="BIO_REFERENCE")
@NamedQuery(name="BioReference.findAll", query="SELECT b FROM BioReference AS b")
public class BioReference
    implements Serializable, Comparable<BioReference>{
    private static final long serialVersionUID = -4321411513685943709L;

    // ----------- 3 Attribute Definitions ------------
    protected String name;
    protected String url;
    protected Long bioReferenceId;

    // --------- 1 Relationship Definitions -----------
    protected Set<Bio> bios = new HashSet<Bio>();

    // ---- Manageable Display Attributes (Transient) -----

    // -------- 3 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Get the name property.
     * @return String The value of name
     */
    @Column(name="NAME", nullable=false, insertable=true, updatable=true)
    @NotNull(message="name is required")
    public String getName()
    {
        return this.name;
    }

    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Set the name property.
     * @param value the new value
     */
    public void setName(String value)
    {
        this.name = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for url
     * </p>
     * Get the url property.
     * @return String The value of url
     */
    @Column(name="URL", nullable=false, insertable=true, updatable=true)
    @NotNull(message="url is required")
    public String getUrl()
    {
        return this.url;
    }

    /**
     * <p>
     * TODO: Model Documentation for url
     * </p>
     * Set the url property.
     * @param value the new value
     */
    public void setUrl(String value)
    {
        this.url = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for bioReferenceId
     * </p>
     * Get the bioReferenceId property.
     * @return Long The value of bioReferenceId
     */
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="BIO_REFERENCE_ID", nullable=false, insertable=true, updatable=true)
    public Long getBioReferenceId()
    {
        return this.bioReferenceId;
    }

    /**
     * <p>
     * TODO: Model Documentation for bioReferenceId
     * </p>
     * Set the bioReferenceId property.
     * @param value the new value
     */
    public void setBioReferenceId(Long value)
    {
        this.bioReferenceId = value;
    }


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for bios
     * </p>
     * Get the bios Collection
     * @return Set<Bio>
     */
    @ManyToMany()
    @JoinTable
    (
        name="BIO_REFERENCES_BIOS",
        joinColumns={@JoinColumn(name="BIO_REFERE_BIO_REFERENCE_ID_FK", referencedColumnName="BIO_REFERENCE_ID")},
        inverseJoinColumns={@JoinColumn(name="BIOS_BIO_ID_FK", referencedColumnName="BIO_ID")}
    )
    public Set<Bio> getBios()
    {
        return this.bios;
    }

    /**
     * <p>
     * TODO: Model Documentation for bios
     * </p>
     * Set the bios
     * @param biosIn
     */
    public void setBios (Set<Bio> biosIn)
    {
        this.bios = biosIn;
    }

    // --------------- Constructors -----------------

    /**
     * Default empty no-arg constructor
     */
    public BioReference()
    {
        // Default empty constructor
    }

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param name String value for the name property required=true lower=1
     * @param url String value for the url property required=true lower=1
     */
    public BioReference(String name, String url)
    {
        this.name = name;
        this.url = url;
    }


    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param name String value for the name property
     * @param url String value for the url property
     * @param bios Set<Bio> value for the bios relation
     */
    public BioReference(String name, String url, Set<Bio> bios)
    {
        // 2 updatableAttributes
        setName(name);
        setUrl(url);

        // 1 relations
        setBios(bios);
    }

    // -------- Common Methods -----------
    /**
     * Indicates if the argument is of the same type and all values are equal.
     * @param object The target object to compare with
     * @return boolean True if both objects a 'equal'
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object object)
    {
        if (null == object)
        {
            return false;
        }
        if (this == object)
        {
            return true;
        }
        if (!(object instanceof BioReference))
        {
            return false;
        }
        final BioReference that = (BioReference)object;
        if (this.getBioReferenceId() == null || that.getBioReferenceId() == null || !this.getBioReferenceId().equals(that.getBioReferenceId()))
        {
            return false;
        }
        return true;
    }

    /**
     * Returns a hash code value for the object
     * @return int The hash code value
     * @see Object#hashCode
     */
    @Override
    public int hashCode()
    {
        int hashCode = 0;
        hashCode = 29 * hashCode + (getBioReferenceId() == null ? 0 : getBioReferenceId().hashCode());

        return hashCode;
    }

    /**
     * Returns a String representation of the object
     * @return String Textual representation of the object displaying name/value pairs for all attributes
     * @see Object#toString
     */
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("BioReference(");
        sb.append(" name=").append(getName());
        sb.append(" url=").append(getUrl());
        sb.append(" bioReferenceId=").append(getBioReferenceId());
        sb.append(" bios=").append(getBios());
        sb.append(")");
        return sb.toString();
    }

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(BioReference o)
    {
        int cmp = 0;
        if (this.getBioReferenceId() != null)
        {
            cmp = this.getBioReferenceId().compareTo(o.getBioReferenceId());
        }
        else
        {
            if (this.getName() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
            }
            if (this.getUrl() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getUrl().compareTo(o.getUrl()));
            }
        }
        return cmp;
    }


}