You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
createtableACCOUNT
(
ID BIGINT auto_increment,
PASSWORD CHARACTER VARYING not null,
FIRST_NAME CHARACTER VARYING,
LAST_NAME CHARACTER VARYING,
EMAIL CHARACTER VARYING not null,
constraint ACCOUNT_PK
primary key (ID)
);
createtableAUTHORITY
(
ID BIGINT auto_increment,
NAME CHARACTER VARYING(16) not null,
constraint AUTHORITY_PK
primary key (ID)
);
createtableACCOUNT_AUTHORITY
(
ID BIGINT auto_increment,
ACCOUNT_ID BIGINTnot null,
AUTHORITY_ID BIGINTnot null,
constraint ACCOUNT_AUTHORITY_PK
primary key (ID)
);
The text was updated successfully, but these errors were encountered:
dzkd2019
changed the title
[错误报告]: 在进行多对多查询时,实际应用中由Spring Security的UserDetailsService调用Service方法得到的结果与测试时直接使用UserDetailsService得到的结果不一致
在进行多对多查询时,实际应用中由Spring Security的UserDetailsService调用Service方法得到的结果与测试时直接使用UserDetailsService得到的结果不一致
Oct 18, 2024
SELECTt.id,t.email,t.password,t.first_name,t.last_nameFROM account t LEFT JOIN ACCOUNT_AUTHORITY t1 ON (t1.account_id=t.id) LEFT JOIN authority t2 ON (t2.id=t1.authority_id) WHERE (t.email='[email protected]')
selectCollections没有查询Authority表中的字段
而测试中生成的SQL为
SELECTt.id,t.email,t.password,t.first_name,t.last_name,t2.idAS joina_id,t2.nameFROM account t LEFT JOIN ACCOUNT_AUTHORITY t1 ON (t1.account_id=t.id) LEFT JOIN authority t2 ON (t2.id=t1.authority_id) WHERE (t.email='[email protected]')
dzkd2019
changed the title
在进行多对多查询时,实际应用中由Spring Security的UserDetailsService调用Service方法得到的结果与测试时直接使用UserDetailsService得到的结果不一致
在进行多对多查询时,由Spring Security调用业务方法中selectCollections方法没有查询到连表的字段,而使用测试类直接调用业务方法selectCollection正常工作
Oct 18, 2024
确认
当前程序版本
1.5.1
问题描述
我是一位初学者,如果问出的问题比较基础/蠢请见谅
我使用H2数据库,有Account与Authority两张表以及一张中间表ACCOUNT_AUTHORITY用于多对多查询,表结构如下:
在
Account
实体类中有@TableField(exist = false) List<Authority> authorities;
的属性,在对应的AccountService
中,我定义了一个方法可以查询该Account所拥有的Authority,方法实现如下:在使用这个方法之前,我编写了一个测试方法:
在测试中方法可以正常工作,查询得到的结果为:
org.springframework.security.core.userdetails.User [[email protected], Password=[PROTECTED], Enabled=true, AccountNonExpired=true, CredentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[ROLE_ADMIN, ROLE_USER, ROLE_SUPER]]
。但当我在web应用中实际使用时,该方法得到的结果为:
查询得到了三条结果,与该Account所拥有三条Authority的事实相符合,但是并没有通过
SelectCollection
映射到authorities
字段上,请问要如何解决这个问题呢?详细堆栈日志
No response
The text was updated successfully, but these errors were encountered: