Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DB;
- import java.io.Serializable;
- import java.util.List;
- import javax.persistence.CascadeType;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.OneToMany;
- import javax.persistence.Table;
- @Entity
- @Table(name = "Country")
- public class Country implements Serializable {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name="id")
- private int id;
- @Column(name="Name", nullable = false, length = 50)
- private String name;
- @Column(name="Continent", nullable = true, length = 20)
- private String continent;
- @OneToMany(mappedBy = "country", cascade=CascadeType.ALL)
- private List<Currency> currencies;
- public Country() {
- }
- public Country(String name, String continent, List<Currency> actors) {
- this.name = name;
- this.continent = continent;
- this.currencies = actors;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public List<Currency> getCurrencies() {
- return currencies;
- }
- public void setCurrencies(List<Currency> currencies) {
- this.currencies = currencies;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getContinent() {
- return continent;
- }
- public void setContinent(String continent) {
- this.continent = continent;
- }
- @Override
- public String toString() {
- return "\n\nCountry: \n id=" + id + "\n Name: " + name
- + "\n Continent: " + continent + "\n Currencies: " + currencies;
- }
- }
Add Comment
Please, Sign In to add comment