mongo使用@Transient不生效
时间: 2023-12-07 22:03:54 浏览: 154
node-mongo:@sealsystemsmongo使轻松可靠地连接到MongoDB变得容易
对于MongoDB数据库中使用@Transient注解不生效的问题,原因在于@Transient注解的导入方式不正确。如果引用的是javax.persistence.Transient,则该注解不会起作用,因为它是JPA标准的注解,对MongoDB无效。正确的导入方式应该是引用org.springframework.data.annotation.Transient注解,该注解可以使字段不被保存到数据库。因此,需要在导入时注意引用的是javax.persistence这个包下的@Transient注解。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Mongo中@Transient依然存入了数据库的解决办法](https://blog.csdn.net/qq_41029282/article/details/112610157)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [@Transient不起作用的问题](https://blog.csdn.net/u011728688/article/details/47403145)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文