我有一个spring启动应用程序 User
以及 Authority
物体。这些连接如下。
用户.java
@OneToMany(mappedBy="user",
cascade={CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.DETACH, CascadeType.REFRESH,
CascadeType.REMOVE})
private List<Authority> authorities;
权威.java
@ManyToOne(cascade= {CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.DETACH, CascadeType.REFRESH})
@JoinColumn(name="member_email", referencedColumnName="email", insertable=false, updatable=false)
private User user;
在抛出 UsernameNotFoundException
. 在进行故障排除时,我意识到执行了以下查询:
select authority0_.authority as authorit1_0_0_, authority0_.member_email as member_e2_0_0_, user1_.id as id1_3_1_, user1_.address_line1 as address_2_3_1_, user1_.address_line2 as address_3_3_1_, user1_.birth_date as birth_da4_3_1_, user1_.country as country5_3_1_, user1_.county as county6_3_1_, user1_.email as email7_3_1_, user1_.first_name as first_na8_3_1_, user1_.gender as gender9_3_1_, user1_.last_name as last_na10_3_1_, user1_.membership_status as members11_3_1_, user1_.mobile as mobile12_3_1_, user1_.password as passwor13_3_1_, user1_.phone as phone14_3_1_, user1_.postcode as postcod15_3_1_, user1_.town as town16_3_1_ from authorities authority0_ left outer join users user1_ on authority0_.member_email=user1_.email where authority0_.authority=? and authority0_.member_email=?
由于只会传入用户名,因此此查询不会返回任何内容。它应该只有where子句 where authority0_.authority=? and authority0_.member_email=?
. 如何更改代码以确保执行正确的查询?
暂无答案!
目前还没有任何答案,快来回答吧!