java - hashset returns only two elements
问题描述
I am trying to make spring boot application. I have to receive set of diary day for each user.
So, I have User class where:
@OneToMany(mappedBy = "users", fetch = FetchType.EAGER)
@OnDelete(action = OnDeleteAction.CASCADE)
private Set<DiaryDay> diaryDays = new HashSet<>();
I have Diary Day Mental and DiaryDayPhysics Classes which extend DiaryDay class (inheritance strategy is join table). And in DiaryDay class i have:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "users")
@OnDelete(action = OnDeleteAction.CASCADE)
private User users;
in diarydayphysicsDao and diarydaymentalDAO i have methods for receiving all diary days for each user(they are similar, so only one example):
public Set findByUserId(Long userId) {
return (Set) getSession().createQuery("from DiaryDayMental where users.id =:userId").setParameter("userId", userId).stream().collect(Collectors.toSet());
}
I added in both tables 3 examples, but i reveived only first from each:
解决方案
推荐阅读
- javascript - 为什么我在 Bootstrap 中的轮播指示器不起作用?
- matlab - 在 MATLAB 中绘制傅里叶级数的直流分量
- java - 将此多播路由(在 Apache-camel 中)从核心 spring 转换为 spring boot 时出错
- javascript - 根据拖动动量 Javascript 找出函数应该被调用的频率
- html - 在引导程序 4 中调整 col 内的跨度值
- powershell - 有人可以帮助正确添加电子邮件功能吗
- sql-server - 识别行中不匹配的记录 - SQL Server
- solr - Hybris如何在SOLR中索引变体
- google-colaboratory - Google Colab 中的 Meshroom 但没有输出文件
- multithreading - 无法让 Asyncio 并行运行 2 个任务(在等待下一个查询完成时处理查询结果)