Item...
Code:
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
@Entity
public class Item {
@Id
private long item_id;
private double price;
@ManyToOne
@JoinColumns({
@JoinColumn(name="seller_firstName", referencedColumnName="firstName", updatable=false),
@JoinColumn(name="seller_lastName", referencedColumnName="lastName", updatable=false),
@JoinColumn(name="seller_birthday", referencedColumnName="birthday", updatable=false)
})
private User seller;
}
User...
Code:
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@Entity
@Table(name="Users", uniqueConstraints = {@UniqueConstraint(columnNames = {"firstName", "lastName", "birthday"})})
public class User {
@Id
private long user_id;
private String firstName;
private String lastName;
private Date birthday;
private String username;
@OneToMany(mappedBy="seller")
private Set<Item> itemsForAuction = new HashSet<Item>();
}