blob: 26d80f88776a74585ba7d77fe8702ea09752baae [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial impl
******************************************************************************/
package model;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlIDREF;
//import com.tangosol.io.pof.PofReader;
//import com.tangosol.io.pof.PofWriter;
//import com.tangosol.io.pof.PortableObject;
/**
* OrderLine, held by Order.
* @author James Sutherland
*/
@Entity
@Table(name="PERF_ORDERLINE")
public class OrderLine implements Serializable { //Externalizable {//, PortableObject {
@Id
@ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
@JoinColumn(name="ORDER_ID")
@XmlIDREF
private Order order;
@Id
@XmlAttribute
private int lineNumber;
@Basic
@XmlAttribute
private String description;
@Basic
@XmlAttribute
private BigDecimal cost = BigDecimal.valueOf(0);
public OrderLine() {
}
/*public void readExternal(PofReader in) throws IOException {
this.lineNumber = in.readInt(0);
this.description = in.readString(1);
this.cost = in.readBigDecimal(2);
this.order = (Order)in.readObject(3);
}
public void writeExternal(PofWriter out) throws IOException {
out.writeInt(0, this.lineNumber);
out.writeString(1, this.description);
out.writeBigDecimal(2, this.cost);
out.writeObject(3, this.order);
}*/
public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException {
this.lineNumber = stream.readInt();
this.description = (String)stream.readObject();
this.cost = (BigDecimal)stream.readObject();
this.order = (Order)stream.readObject();
}
public void writeExternal(ObjectOutput stream) throws IOException {
stream.writeInt(this.lineNumber);
stream.writeObject(this.description);
stream.writeObject(this.cost);
stream.writeObject(this.order);
}
public OrderLine(String description, BigDecimal cost) {
this.description = description;
this.cost = cost;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public BigDecimal getCost() {
return cost;
}
public void setCost(BigDecimal cost) {
this.cost = cost;
}
}