Bio.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:03.
//
package org.andromda.demo.ejb3.bio;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
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.Bio
 * </p>
 *
 * Autogenerated POJO EJB class for Bio 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")
@NamedQuery(name="Bio.findAll", query="SELECT b FROM Bio AS b")
public class Bio
    implements Serializable, Comparable<Bio>{
    private static final long serialVersionUID = -6231274770616781834L;

    // ----------- 5 Attribute Definitions ------------
    protected String name;
    protected String info;
    protected byte[] picture;
    protected char[] advert;
    protected Long bioId;

    // --------- 1 Relationship Definitions -----------
    protected Set<BioReference> bioReferences = new HashSet<BioReference>();

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

    // -------- 5 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 info
     * </p>
     * Get the info property.
     * @return String The value of info
     */
    @Lob
    @Column(name="INFO", nullable=false, insertable=true, updatable=true)
    @NotNull(message="info is required")
    public String getInfo()
    {
        return this.info;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for picture
     * </p>
     * Get the picture property.
     * @return byte[] The value of picture
     */
    @Lob
    @Column(name="PICTURE", nullable=false, insertable=true, updatable=true)
    @NotNull(message="picture is required")
    public byte[] getPicture()
    {
        return this.picture;
    }

    /**
     * <p>
     * TODO: Model Documentation for picture
     * </p>
     * Set the picture property.
     * @param value the new value
     */
    public void setPicture(byte[] value)
    {
        this.picture = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for advert
     * </p>
     * Get the advert property.
     * @return char[] The value of advert
     */
    @Lob
    @Column(name="ADVERT", nullable=false, insertable=true, updatable=true)
    @NotNull(message="advert is required")
    public char[] getAdvert()
    {
        return this.advert;
    }

    /**
     * <p>
     * TODO: Model Documentation for advert
     * </p>
     * Set the advert property.
     * @param value the new value
     */
    public void setAdvert(char[] value)
    {
        this.advert = value;
    }

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

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


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for bioReferences
     * </p>
     * Get the bioReferences Collection
     * @return Set<BioReference>
     */
    @ManyToMany(cascade={CascadeType.ALL}, mappedBy="bios", fetch=FetchType.EAGER)
    public Set<BioReference> getBioReferences()
    {
        return this.bioReferences;
    }

    /**
     * <p>
     * TODO: Model Documentation for bioReferences
     * </p>
     * Set the bioReferences
     * @param bioReferencesIn
     */
    public void setBioReferences (Set<BioReference> bioReferencesIn)
    {
        this.bioReferences = bioReferencesIn;
    }

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

    /**
     * Default empty no-arg constructor
     */
    public Bio()
    {
        // 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 info String value for the info property required=true lower=1
     * @param picture byte[] value for the picture property required=true lower=1
     * @param advert String value for the advert property required=true lower=1
     */
    public Bio(String name, String info, byte[] picture, char[] advert)
    {
        this.name = name;
        this.info = info;
        this.picture = picture;
        this.advert = advert;
    }


    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param name String value for the name property
     * @param info String value for the info property
     * @param picture byte[] value for the picture property
     * @param advert String value for the advert property
     * @param bioReferences Set<BioReference> value for the bioReferences relation
     */
    public Bio(String name, String info, byte[] picture, char[] advert, Set<BioReference> bioReferences)
    {
        // 4 updatableAttributes
        setName(name);
        setInfo(info);
        setPicture(picture);
        setAdvert(advert);

        // 1 relations
        setBioReferences(bioReferences);
    }

    // -------- 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 Bio))
        {
            return false;
        }
        final Bio that = (Bio)object;
        if (this.getBioId() == null || that.getBioId() == null || !this.getBioId().equals(that.getBioId()))
        {
            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 + (getBioId() == null ? 0 : getBioId().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("Bio(");
        sb.append(" name=").append(getName());
        sb.append(" info=").append(getInfo());
        sb.append(" picture=").append(getPicture());
        sb.append(" advert=").append(getAdvert());
        sb.append(" bioId=").append(getBioId());
        sb.append(")");
        return sb.toString();
    }

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


}