jpa 使用@query 查询
//数据
@Query( value = "select orders.*, user_orders.uid from orders,address,user_orders where user_orders.oid=orders.id and address.sphone=?1 and orders.id=address.oid",nativeQuery = true)
List<Orders> findByPhone(String phone);
我的本意是只查询一个orders表,发现它自动会查询关联的表,但是如果是多对多关系,比如关联了user,中间表的uid字段它查不出来就会报错,如上额外查询uid就行,如果你不想重建一个类的话。
没有中间表的就自动查询不会报错,嗯,又是凌乱的一天