hibernate - java.sql.SQLTransientConnectionException: (conn=15) 表太多;MariaDB 在一个连接中只能使用 61 个表
问题描述
我是 JPA 的初学者,在从我的 DAO 访问数据库时,会弹出一个错误,指出 MariaDB 在连接中被限制为 61 个表。
这是实体代码的一部分
@Entity
@Table(name = "service")
@NamedQuery(name = "Department.findAll", query = "SELECT d FROM Department d")
public class Department implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "nom")
private String name;
private byte status;
@OneToMany(mappedBy = "department", fetch = FetchType.EAGER)
private Set<OperatingBloc> operatingBlocs;
@OneToMany(mappedBy = "depatment", fetch = FetchType.EAGER)
private Set<Room> rooms;
...
}
还有我的 DAO 代码的模型
@Stateless
public class DepartmentDAO implements DepartmentDAORemote, DepartmentDAOLocal {
@PersistenceContext
EntityManager em;
@Override
public List<Department> getAllDepartments() {
return em.createNamedQuery("Department.findAll", Department.class).getResultList();
}
...
}
每次我访问getAllDepartments()
我的 DAO 的方法可能超过两次或三次时,我都会收到以下错误
org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
...
Caused by: java.sql.SQLTransientConnectionException: (conn=15) Too many tables; MariaDB can only use 61 tables in a join
...
我总共有 40 个表,因此有 40 个实体,每个实体的 DAO 编码方式与上述相同,所以我的问题与我可能做错的任何事情有关,以及我将如何纠正它。
数据库使用 JPA 2.2,MariaDB。
解决方案
推荐阅读
- powershell - 无法从 Azure DevOps Release 获取自定义变量值
- jquery - 溢出块滚动脚本
- instagram - Instagram Hashtag Search API 返回错误消息“user_id is required”,尽管我已经提供了它
- android - 测试失败时如何生成 AndroidTestCoverageReport?
- html - 重新定位材料标签控件
- swift - XLPagerTabstrip 。如何从另一个选项卡更新栏标题
- r - 按类别的多个直方图
- virtualization - 具有半虚拟化来宾的虚拟机管理程序能否从虚拟化扩展中受益?
- python - 快速傅里叶变换调整缩放
- javascript - 为什么要在绑定 jQuery 事件监听器之前指定“document”或“body”?