第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

保存實體后,Hibernate對于以@Formula注釋的實體屬性返回null

保存實體后,Hibernate對于以@Formula注釋的實體屬性返回null

牧羊人nacy 2021-04-07 17:15:13
我有一個簡單的類,如下所示:@Entity@Table(name = "post")public class Post {    @Id    @GeneratedValue    Long id;    @Column(name = "title")    String title;    @Formula("(select current_date())")    Date currentDate;    @OneToMany(mappedBy = "post")    Set<PostComment> commentList = new HashSet<>();}并希望在服務(wù)中更新此實體:@Service@Transactionalpublic class PostService {    private final PostRepository postRepository;    public PostService(PostRepository postRepository) {        this.postRepository = postRepository;    }    @Transactional    public Post save(Post entity) {        Post post = postRepository.saveAndFlush(entity);        System.out.println("current_date: " + post.getCurrentDate());        post.getCommentList().forEach(pc -> System.out.println(pc.getReview()));        return post;    }}當(dāng)我檢查休眠日志時,它首先select是Post實體的所有字段,但是當(dāng)我調(diào)用post.getCurrentDate()(用注釋@Formula)時返回null:Hibernate: select post0_.id as id1_0_0_, post0_.title as title2_0_0_, (select current_date()) as formula0_0_ from post post0_ where post0_.id=?Hibernate: update post set title=? where id=?current_date: nullHibernate: select commentlis0_.post_id as post_id3_1_0_, commentlis0_.id as id1_1_0_, commentlis0_.id as id1_1_1_, commentlis0_.post_id as post_id3_1_1_, commentlis0_.review as review2_1_1_ from post_comments commentlis0_ where commentlis0_.post_id=?review為什么返回并記錄commentList但不返回currentDate?是冬蟲嗎?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 294 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號