bug fix: "could not initialize proxy - no Session"

This commit is contained in:
myh 2023-12-03 23:46:58 +08:00
parent a17444abdb
commit d2187c4913
5 changed files with 8 additions and 8 deletions

View File

@ -25,7 +25,7 @@ public class Merchants {
private String description;//店铺描述
//商家和菜品是一对多的关系有mappedBy的时候表示Merchants的dishes 字段放弃维护权而将维护权交给了Dishes的关联属性merchants
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "merchants_dishes",
joinColumns = @JoinColumn(name = "merchantsId"),
inverseJoinColumns = @JoinColumn(name = "dishesId"))

View File

@ -23,7 +23,7 @@ public class Orders {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//订单ID
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "orders_orderDishes",
joinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "orderDishesId", referencedColumnName = "id")})

View File

@ -14,8 +14,8 @@ public class Permissions {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//主键权限ID
@Column(name = "description")
private String description;//权限名称
@Column(name = "name")
private String name;//权限名称
@Column(name = "url")
private String url;//权限对应的URL
}

View File

@ -17,11 +17,11 @@ public class RolesPermissions {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//主键
@OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@Column(name = "rolesId")
private List<Roles> roles;//角色ID
@OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@Column(name = "permissionsId")
private List<Permissions> permissions;//权限ID
}

View File

@ -25,13 +25,13 @@ public class Users {
private String address;//家庭住址
//一个用户可能会有多个订单关系是一对多
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "users_orders",
joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")})
private List<Orders> orders;//订单
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "users_roles",
joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "rolesId", referencedColumnName = "id")})