test bug: Error creating bean with name 'entityManagerFactory'
This commit is contained in:
parent
fe78942add
commit
1ffca36f10
@ -1,10 +1,10 @@
|
||||
package com.example.springdemo.dao;
|
||||
|
||||
import com.example.springdemo.entities.Orders;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface OrdersRepository
|
||||
extends CrudRepository<Orders, Long> {
|
||||
extends JpaRepository<Orders, Long> {
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ public class Dishes {
|
||||
private BigDecimal finalPrice;//菜品最终价格
|
||||
private String description;//菜品描述
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "merchants_dishes",
|
||||
joinColumns = {@JoinColumn(name = "dishesID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "merchantsID", referencedColumnName = "id")})
|
||||
private Merchants merchants;//商家
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@ -23,6 +22,9 @@ public class Merchants {
|
||||
private String description;//店铺描述
|
||||
|
||||
//商家和菜品是一对多的关系,有mappedBy的时候,表示Merchants的dishes 字段放弃维护权,而将维护权交给了Dishes的关联属性merchants
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "merchants")
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "Merchants_Dishes",
|
||||
joinColumns = @JoinColumn(name = "merchantsID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "dishesID"))
|
||||
private List<Dishes> dishes = new ArrayList<>();//菜品
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class OrderDishes {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;//主键ID
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@PrimaryKeyJoinColumn(name = "dishesID", referencedColumnName = "id")
|
||||
private Dishes dishes;//菜品ID
|
||||
|
||||
@ -26,7 +26,9 @@ public class OrderDishes {
|
||||
@PrimaryKeyJoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
private Merchants merchants;//商家ID
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "ordersID", referencedColumnName = "id")
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "orders_orderDishes",
|
||||
joinColumns = @JoinColumn(name = "orderDishesID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "ordersID"))
|
||||
private Orders orders;//订单ID
|
||||
}
|
@ -11,7 +11,6 @@ import java.util.List;
|
||||
|
||||
//订单类
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@ -21,12 +20,17 @@ public class Orders {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;//订单ID
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "orders")
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "orders_orderDishes",
|
||||
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "orderDishesID", referencedColumnName = "id")})
|
||||
private List<OrderDishes> orderDishes = new ArrayList<>();//订单中的菜品
|
||||
|
||||
//多个订单对应一个用户,关系是多对一,订单创建后添加用户ID,可以主动改变关系,因此是主控方
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable()
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_orders",
|
||||
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")})
|
||||
private Users user;//外键,下单用户
|
||||
|
||||
@Column(name = "allPrice")
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "RolesPermissions")
|
||||
@Table(name = "roles_permissions")
|
||||
public class RolesPermissions {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
@ -28,11 +28,15 @@ public class Users {
|
||||
private String address;//家庭住址
|
||||
|
||||
//一个用户可能会有多个订单,关系是一对多
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "id")
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_orders",
|
||||
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")})
|
||||
private List<Orders> orders = new ArrayList<>();//订单
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "rolesID", referencedColumnName = "id")
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_roles",
|
||||
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "rolesID", referencedColumnName = "id")})
|
||||
private Roles roles;//RBAC角色
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user