这可能看起来很基本,但为时已晚,我在以下方面遇到了麻烦。
class Group {
@Id
String id;
}
class Participation {
@Id
String id;
@ManyToOne
@JoinColumn(name = "GROUP_ID")
Group group;
@ManyToOne
@JoinColumn(name = "USER_ID")
User user;
}
class User {
@Id
String id;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
Set<Participation> participations;
}
Run Code Online (Sandbox Code Playgroud)
所以
参与-->1组
和用户 1<-->N 参与
对于给定的用户,我如何检索所有具有关联参与的组(或 null 表示没有参与)?我一直在玩连接提取,但到目前为止无济于事......
非常感谢,
中国网
附注。因此,我可以在 SQL 中执行此操作:
select g.d, p.id
from group as g
left join participation as p
on p.group_id = g.id and p.user_id = 2;
Run Code Online (Sandbox Code Playgroud) 我有一个 Ant Design 表格,具有排序、选择和分页功能。默认情况下(如果我理解正确的话),Antd 表选择是在每页的基础上进行的。如果您单击选择列标题中的“全选”复选框,Antd 将选择当前页面上的所有行,但如果您随后更改页面,行和标题都将恢复为未选中状态。选择不会丢失,因为如果您返回到上一页,行和标题都会被选中。
所以我想改变这一点,以便“全选”真正选择表的所有行,而不管分页。我发现了一些 github 问题,其中建议简单地自己管理 selectedRowKeys 数组 onSelect 和 onSelectAll 函数。我这样做了,现在我的选择按预期工作了......
然而...
选择列标题中的“全选”复选框对于页面行仍然起作用。因此,例如,如果我在第一页上“全选”,然后取消选择其中一行,则“全选”复选框将按预期处于中间/部分状态。但是,如果我然后转到下一页,所有行都会按预期进行检查,标题中的“全选”复选框也是如此。为了使此选择在功能上有意义,需要保持中间/部分状态。它需要反映整个数据集的选择,而不仅仅是当前页面。
这可以在这个简单的示例中看到:https ://codesandbox.io/s/antd-table-selection-ikqym
有什么想法如何覆盖“全选”复选框吗?
干杯
我正在使用 Ant Design,但我在使用 Forms 时遇到了以下问题。
我有一个自定义组件,它用远程获取自动完成建议所需的代码包装了一个 antd AutoComplete:
const ProductComplete = () => {
const [value, setValue] = React.useState('')
const [options, setOptions] = React.useState([])
const onSearch = searchText => {
fetchProductsFromServer(searchText)
.then(options => options.map(o => ({value: o})))
.then(options => setOptions(options))
}
const onChange = data => {
setValue(data)
}
return (
<AutoComplete
value={value}
options={options}
onSearch={onSearch}
onChange={onChange}
/>
)
}
Run Code Online (Sandbox Code Playgroud)
但是当我以 antd 形式使用它时:
return (
<Form
{...formLayout}
ref={this.formRef}
>
<Form.Item
name={'product'}
label={'Product'}
rules={[{
required: true
}]}
>
<ProductComplete/>
</Form.Item>
</Form>
Run Code Online (Sandbox Code Playgroud)
当我因此 …
我是 MongoDB 新手,正在为 Mongo 支持的 REST Web 服务编写一系列单元测试。这是 /clients/{id} enpoint 的简单测试:
@RunWith(MockitoJUnitRunner.class)
public class ClientsControllerMockMvcStandaloneTest {
private MockMvc mvc;
@Mock
private ClientsRepository clientsRepository;
@Mock
private ModelMapper modelMapper;
@InjectMocks
private ClientsController clientsController;
private ExceptionHandlerExceptionResolver createExceptionResolver() {
ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() {
@SuppressWarnings("ConstantConditions")
@Override
protected ServletInvocableHandlerMethod getExceptionHandlerMethod(final HandlerMethod handlerMethod,
final Exception exception) {
final Method method = new ExceptionHandlerMethodResolver(RestResponseEntityExceptionHandler.class)
.resolveMethod(exception);
final RestResponseEntityExceptionHandler handler = new RestResponseEntityExceptionHandler();
return new ServletInvocableHandlerMethod(handler, method);
}
};
exceptionResolver.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
exceptionResolver.afterPropertiesSet();
return exceptionResolver;
}
@Before
public void …Run Code Online (Sandbox Code Playgroud) antd ×2
reactjs ×2
forms ×1
hibernate ×1
hql ×1
html-table ×1
java ×1
javascript ×1
join ×1
mockito ×1
modelmapper ×1
mongodb ×1
rest ×1
spring ×1
sql ×1