Account.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.account;

import java.io.Serializable;
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.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.Size;
import org.andromda.demo.ejb3.user.User;

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

    // ----------- 3 Attribute Definitions ------------
    protected Long id;
    protected String name;
    public Long modified;

    // --------- 1 Relationship Definitions -----------
    protected User user;

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

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

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

    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Get the name property.
     * @return String The value of name
     */
    @Column(name="NAME", insertable=true, updatable=true, length=50)
    @Size(max=50)
    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 modified
     * </p>
     * Get the modified property.
     * @return Long The value of modified
     */
    @Version
    public Long getModified()
    {
        return this.modified;
    }

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


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for user
     * </p>
     * Get the user
     * @return User
     */
    @OneToOne(optional=false)
    @JoinColumn(name="USER_FK")
    public User getUser()
    {
        return this.user;
    }

   /**
     * <p>
     * TODO: Model Documentation for user
     * </p>
    * Set the user
    * @param userIn
    */
    public void setUser(User userIn)
    {
        this.user = userIn;
    }

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

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

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param name String value for the name property required=false lower=0
     */
    public Account(String name)
    {
        this.name = name;
    }


    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param name String value for the name property
     * @param user User value for the user relation
     */
    public Account(String name, User user)
    {
        // 1 updatableAttributes
        setName(name);

        // 1 relations
        setUser(user);
    }

    /**
     * Constructor with required Entity attribute values and required CMR relations.
     *
     * @param user User value for the user relation
     */
    public Account(User user)
    {

        // 1 required association relations
        setUser(user);
    }

    // -------- 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 Account))
        {
            return false;
        }
        final Account that = (Account)object;
        if (this.getId() == null || that.getId() == null || !this.getId().equals(that.getId()))
        {
            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 + (getId() == null ? 0 : getId().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("Account(");
        sb.append(" id=").append(getId());
        sb.append(" name=").append(getName());
        sb.append(" modified=").append(getModified());
        sb.append(" user=").append(getUser());
        sb.append(")");
        return sb.toString();
    }

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


}