我将 Spring Data JPA 与 Spring Boot 版本 1.3.6.RELEASE 与内存数据库一起使用。
我想知道如何从父实体对子实体进行分页。将 fetch 设置为LAZY对我来说不是解决方案。
这是用例:
这是一个代码示例:
@Entity
public class Parent{
@Id
private Integer id;
@OneToMany
private List<Child> childs;
}
@Entity
public class Child {
@Id
private Integer id;
}
public interface ParentRepository extends JpaRepository<Parent, Integer>{}
public interface ChildRepository extends JpaRepository<Child, Integer>{}
Run Code Online (Sandbox Code Playgroud)
我在父存储库中尝试过这个失败:
Page<Child> findById(int id, Pageable pageable);
Run Code Online (Sandbox Code Playgroud)
这将返回父实体,而不是子实体。
知道如何做到这一点吗?
I'm trying to configure Spring Boot and Keycloak for SSO. I've created a basic AngularJS application that do some requests to the Spring boot backend. using this
The Angular app is working fine and now I'm trying to follow the new Spring Boot Keycloak apdater docuementation here
This is my keycloak.json that is in the WEB-INF folder.
{
"realm": "my-backend",
"bearer-only": true,
"realm-public-key": "MIIB...",
"auth-server-url": "http://localhost:8180/auth",
"ssl-required": "external",
"resource": "my-backend",
"principal-attribute": "preferred_username",
"credentials": {
"secret": "a75f55ca-8174-4072-8c60-b545c9ebf7e1"
}
Run Code Online (Sandbox Code Playgroud)
Here is my …