-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
in: coreIssues in core supportIssues in core supportstatus: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: bugA general bugA general bug
Description
eacdy opened DATAMONGO-2146 and commented
I use Spring Boot 2.1.0 with Spring Data Mongo Reactive.
When I call http://localhost:8080/query or http://localhost:8080/query2
I Can only get an error messge like below:
Whitelabel Error PageThis application has no configured error view, so you are seeing this as a fallback.Wed Nov 28 01:35:02 CST 2018There was an unexpected error (type=Internal Server Error, status=500).DBRef resolution is not supported!
When I downgrade to Spring Boot 2.0.6, everything turns OK.
Code is like below: I've uploaded.[^odin.zip]
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
@Repository
public interface UserRepository extends ReactiveCrudRepository<User, String> {
Mono<User> findByCompanyId(String companyId);
Mono<User> findByCompany(Company company);
@Query("{'company.$id': ?0}")
Mono<Company> findByCompanyId2(String companyId);
}
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserController {
private final UserRepository userRepository;
private final CompanyRepository companyRepository;
@GetMapping("/users/{id}")
public Mono<User> findOne(@PathVariable Integer id) {
Company company = Company.builder()
.name("阿里巴巴")
.build();
User user = User.builder()
.username("张三123123")
.password("密码")
.company(company)
.build();
Mono<Company> companyMono = this.companyRepository.save(company);
Mono<User> userMono = this.userRepository.save(user);
return companyMono.then(userMono);
}
@GetMapping("query")
public Mono<User> query() {
Mono<User> byCompanyId = this.userRepository.findByCompanyId("5bfd7057ce58a2202e9ab105");
byCompanyId.subscribe(System.out::println);
return byCompanyId;
}
@GetMapping("query2")
public Mono<User> query2() {
Mono<User> byCompanyId = this.userRepository.findByCompany(
Company.builder()
.id("5bfd7057ce58a2202e9ab105")
.build()
);
byCompanyId.subscribe(System.out::println);
return byCompanyId;
}
@GetMapping("query3")
public Mono<Company> query3() {
Mono<Company> byCompanyId = this.userRepository.findByCompanyId2("5bfd7057ce58a2202e9ab105");
byCompanyId.subscribe(System.out::println);
return byCompanyId;
}
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document
// 如果不指定,那就是包名全路径
@TypeAlias("company_xx")
public class Company {
@Id
private String id;
private String name;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document
public class User {
/**
* ID
*/
@Id
private String id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
@DBRef
private Company company;
}
Affects: 2.1.3 (Lovelace SR3)
Attachments:
- odin.zip (10.97 kB)
Issue Links:
- DATAMONGO-1584 Support DBRef in Spring Data Mongo Reactive
Metadata
Metadata
Assignees
Labels
in: coreIssues in core supportIssues in core supportstatus: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: bugA general bugA general bug