/* * ============================================================================ * GNU Lesser General Public License * ============================================================================ * * Taylor - The Java Enterprise Application Framework. * Copyright (C) 2005 John Gilbert jgilbert01@users.sourceforge.net * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * John Gilbert * Email: jgilbert01@users.sourceforge.net */ package com.fermland.ejb.jpa.entity; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * @todo add comment for javadoc * * @author Berni * @generated */ @Entity(name="commande") public class Commande implements Serializable, Cloneable { /** @generated */ private static final long serialVersionUID = 1L; /** @generated */ public Commande() { } /** * ------------------------------------------------------------------------ * The primary key. * ------------------------------------------------------------------------ * @generated */ @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } /** @generated */ public void setId(final Long id) { this.id = id; } /** @generated */ private Long id = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ @Temporal(value = TemporalType.TIMESTAMP) public Date getDate() { return date; } /** @generated */ public void setDate(final Date date) { this.date = date; } /** @generated */ private Date date = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ public Double getTotal() { return total; } /** @generated */ public void setTotal(final Double total) { this.total = total; } /** @generated */ private Double total = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ @OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}, mappedBy="commande") public List getLignes() { if (this.lignes == null) { this.lignes = new ArrayList(); } return lignes; } /** @generated */ public void setLignes(final List lignes) { this.lignes = lignes; } /** * Associate Commande with LigneCommande * @generated */ public void addLigne(LigneCommande ligne) { if (ligne == null) { return; } getLignes().add(ligne); ligne.setCommande(this); } /** * Unassociate Commande from LigneCommande * @generated */ public void removeLigne(LigneCommande ligne) { if (ligne == null) { return; } getLignes().remove(ligne); ligne.setCommande(null); } /** * @generated */ public void removeAllLignes() { List remove = new ArrayList(); remove.addAll(getLignes()); for (LigneCommande element : remove) { removeLigne(element); } } /** @generated */ private List lignes = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ @OneToOne public Client getClient() { return client; } /** @generated */ public void setClient(final Client client) { this.client = client; } /** @generated */ private Client client = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ @OneToOne public PointLivraison getPointLivraison() { return pointLivraison; } /** @generated */ public void setPointLivraison(final PointLivraison pointLivraison) { this.pointLivraison = pointLivraison; } /** @generated */ private PointLivraison pointLivraison = null; /** * ------------------------------------------------------------------------ * @todo add comment for javadoc * ------------------------------------------------------------------------ * @generated */ @OneToOne public Libelle getStatut() { return statut; } /** @generated */ public void setStatut(final Libelle statut) { this.statut = statut; } /** @generated */ private Libelle statut = null; // ------------------------------------------------------------------------ // Utils // ------------------------------------------------------------------------ /** @generated */ public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } /** @generated */ public Commande deepClone() throws Exception { Commande clone = (Commande) super.clone(); clone.setId(null); clone.setLignes(null); for (LigneCommande kid : this.getLignes()) { clone.addLigne(kid.deepClone()); } return clone; } /** @generated */ @Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((id == null) ? super.hashCode() : id.hashCode()); return result; } /** @generated */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Commande)) return false; final Commande other = (Commande) obj; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; return true; } }