我有2个单向关联的实体。
第一个
以及三个表albums、album_cards和album_album_cards(用于Map)
将实体Map到模型时,会引发异常。
第一次
最后一个sql日志为
Hibernate: select album0_.id as id1_1_, album0_.is_public as is_publi2_1_, album0_.name as name3_1_, album0_.owner_id as owner_id4_1_ from albums album0_ where album0_.owner_id=? and album0_.id=?
Hibernate: select cards0_.album_id as album_id8_0_0_, cards0_.id as id1_0_0_, cards0_.id as id1_0_1_, cards0_.card_id as card_id2_0_1_, cards0_.condition as conditio3_0_1_, cards0_.count as count4_0_1_, cards0_.design as design5_0_1_, cards0_.price as price6_0_1_, cards0_.updated as updated7_0_1_ from album_cards cards0_ where cards0_.album_id=?
Map器代码:
51 protected List<AlbumPositionModel> albumCardListToAlbumPositionModelList(List<AlbumCard> list) {
52 if (list == null) {
53 return new ArrayList<>();
54 }
55
56 List<AlbumPositionModel> list1 = new ArrayList<>();
57 list.forEach(e -> list1.add(albumCardToAlbumPositionModel(e))); <---- exception throws there. And it throws if i call any method of list (List<AlbumCard>)
58 return list1;
调用Map器的服务方法(我尝试使用事务注解,没有事务注解,结果相同):
@Override
public Optional<AlbumModel> getAlbum(String ownerId, Long albumId) {
if (ownerId != null) {
return albumRepo
.findByOwnerIdAndId(ownerId, albumId)
.map(mapper::toModel);
} else {
return albumRepo
.findByIdAndIsPublic(albumId, true)
.map(mapper::toModel);
}
}
有人能帮我吗?我做错了什么?
1条答案
按热度按时间cxfofazt1#
尝试将
count
列重命名为至