Spring Boot JPA 对象传参

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/suo082407128/article/details/97380329

在使用JPA的过程中遇到一些坑,save()方法在进行Update操作的时候,null属性也更新到数据库了,查了很多资料,解决方案都不完美,还不如自己写update语句,写update的时候,不想写那么长的方法参数,直接传递对象多好,查资料发现网上给到很多方案都不正确,最终才在stack上找到正解,这里记录下,同时方便后来同学少走弯路

@Query("select u from User u where u.firstname = :#{#customer.firstname}")
List<User> findUsersByCustomersFirstname(@Param("customer") Customer customer);

猜你喜欢

转载自blog.csdn.net/suo082407128/article/details/97380329