Java Reference
In-Depth Information
import javax.persistence.ManyToOne;
import org.glassfish.internal.embedded.ScatteredArchive.Builder.type;
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="PRODUCT_TYPE", discriminatorType=DiscriminatorType.STRING,length=20)
@DiscriminatorValue("A")
public abstract class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name="NAME")
String name;
@Column(name="DESCRIPTION")
String description;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="FACTORY_ID", referencedColumnName="ID")
private Factory factory;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Product)) {
return false;
}
Product other = (Product) object;
if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.
id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "org.javaee7.entity.Factory[ id=" + getId() + " ]";
}
Search WWH ::




Custom Search