我有一个 JsonIgnore 问题我正在考虑构建一个具有 JsonIgnore 注释的对象和一个没有它的对象。当我尝试使用新对象时,它仍在使用旧对象 - 我错过了什么?这是新代码(CategoryIgnoreJson 是我创建的新类) @GET@Produces(MediaType.APPLICATION_JSON)@Path("getCategoriesQandA")public List<CategoryIgnoreJson> getCategoriesQandA() { ediUtils = new EDIUtils(SYSTEM_NAME, USER_NAME); Init(ediUtils); ediUtils.writeToLog("get Categories , questions and answers "); List<CategoryIgnoreJson> categoriesArray; categoriesArray = categoryIgnoreJsonRepository.getEffective(); return categoriesArray;}我还创建了新的存储库public interface CategoryIgnoreJsonRepository extends JpaRepository<CategoryIgnoreJson, Long>{@Transactional @Modifying@Query("update Category set expiration_date = current_date() where category_id = ?1 ")void expireCategory(Long id ); @Query("from Category where function ('coalesce' ,effectiveDate ,current_date() ) <= current_date() " + "and function('coalesce' ,expirationDate , to_date('50001231','yyyymmdd')) > current_date() ")List<CategoryIgnoreJson> getEffective( );}我可以在日志文件中看到旧的类别仍然被称为我还将旧类别中的表名从类别更改为类别 1(只是为了验证此代码被调用)并得到预期的错误edi_ms.categories1" does not exist我如何称呼新班级?我错过了什么?
1 回答

慕哥9229398
TA贡献1877条经验 获得超6个赞
发现问题我还需要将选择更改为
@Query("from CategoryIgnoreJson ..."
还要更改映射的值以引用在父级中映射到的对象的名称(在 CatagoryIgnoreJson.java 中)
@OneToMany(fetch = FetchType.EAGER, mappedBy = "categoryIgnoreJson")
@Fetch(FetchMode.SUBSELECT)
@NotFound(action = NotFoundAction.IGNORE)
public List<QuestionIgnoreJson> getQuestions() {
return this.questions;enter code here
添加回答
举报
0/150
提交
取消