jHispster項目在控制器中用於避免LazyInitializationException的設置是什麼?爲什麼jHipster項目在Controller中沒有得到LazyInitializationException?
我的控制器:
@GetMapping("/citys")
@Timed
public ResponseEntity<List<City>> getAllCidades(@ApiParam Pageable pageable) {
log.debug("REST request to get a page of Citys");
Page<City> page = cityService.findAll(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/citys");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
城市實體:
@Entity
@Table(name = "city")
public class Cidade implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
@ManyToOne(optional = false)
@NotNull
private State state;
...
// gets and sets
}