В чем может быть проблема? Все таблицы и связи создались кроме одной(Order
).
Возможно кто-то сможет понять в чем ошибка.
@Table(name="order")
@Entity
public class Order implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="user_id", nullable=false)
private Account user;
@OneToMany(fetch=FetchType.LAZY, mappedBy="order")
private List<Dish> dishes;
@Column(name="order_date")
@Temporal(TemporalType.TIMESTAMP)
private Calendar orderDate;
@Column(name="order_status", nullable=false)
@Enumerated(EnumType.STRING)
private OrderStatus status;
@Column(name="amount")
private Double amount;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public Account getUser() {
return user;
}
public void setUser(Account user) {
this.user = user;
}
public List<Dish> getDishes() {
return dishes;
}
public void setDishes(List<Dish> dishes) {
this.dishes = dishes;
}
public Calendar getOrderDate() {
return orderDate;
}
public void setOrderDate(Calendar orderDate) {
this.orderDate = orderDate;
}
public OrderStatus getStatus() {
return status;
}
public void setStatus(OrderStatus status) {
this.status = status;
}
}
@Table(name="account")
@Entity
public class Account extends DomainBase implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
@GeneratedValue
private Long id;
@Column(name = "username", length = 50, unique = true)
private String username;
@Column(name = "password", length = 100)
private String password;
@Column(name = "firstname", length = 50)
private String firstname;
@Column(name = "lastname", length = 50)
private String lastname;
@Column(name = "email", length = 50)
private String email;
@Column(name = "enabled")
private Boolean enabled;
@Column(name = "lastpasswordresetdate")
@Temporal(TemporalType.TIMESTAMP)
private Date lastPasswordResetDate;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "user_authority",
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "authority_id", referencedColumnName = "id")})
private List<Authority> authorities;
@Column(name = "authority")
private String authority;
@OneToMany(mappedBy="user", fetch=FetchType.LAZY)
private List<Order> order;
public String getAuthority() {
return authority;
}
public void setAuthority(String authority) {
this.authority = authority;
}
public Long getId() {
return id;
}
public List<Order> getOrder() {
return order;
}
public void setOrder(List<Order> order) {
this.order = order;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public Date getLastPasswordResetDate() {
return lastPasswordResetDate;
}
public void setLastPasswordResetDate(Date lastPasswordResetDate) {
this.lastPasswordResetDate = lastPasswordResetDate;
}
public List<Authority> getAuthorities() {
return authorities;
}
public void setAuthorities(List<Authority> authorities) {
this.authorities = authorities;
}
}
@Table(name="dish")
@Entity
public class Dish implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Column(nullable=false)
private String name;
@Column
private Double weight;
@Column
private Double price;
@Column
private String description;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="order_id", nullable=false)
private Order order;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="category_id", nullable=false)
private Category category;
@ManyToMany(cascade=CascadeType.ALL)
@JoinTable(name="dish_ingredients",
joinColumns={@JoinColumn(name="dish_id")},
inverseJoinColumns={@JoinColumn(name="ingredient_id")})
private List<Ingredient> ingredients;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getWeight() {
return weight;
}
public void setWeight(Double weight) {
this.weight = weight;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
public List<Ingredient> getIngredients() {
return ingredients;
}
public void setIngredients(List<Ingredient> ingredients) {
this.ingredients = ingredients;
}
}
order
- зарезервированное слово в sql, и создавать таблицу с таким именем не очень разумно.