I have an ElementType object that has a EquipmentCodes set:
@Entity
@Table(name = "ELEMENT_TYPES")
public class ElementType extends AbstractEntity<Long> {
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name= "ELEM_TYPE_ID")
private Set<EquipmentCode> equipmentCodes;
}
I have both classes that display as Rest Rest resources with repositories:
@RepositoryRestResource(path = "elementTypes", collectionResourceRel = "elementTypes")
@Transactional
public interface ElementTypeRepository extends CrudRepository<ElementType, Long> {}
Now, if I try to perform some operations, for example
GET https: // localhost: 8080 / api / elementTypes / 40529090
or sending PATCH
{
"equipmentCodes" : [
"https://localhost:8080/api/equipmentCodes/40529100"
]
}
Everything seems to work fine if I try to add new hardware code to existing ones:
[
{
"op": "add",
"path": "/equipmentCodes",
"value": [
"https://localhost:8080/api/equipmentCodes/40529099"
]
}
]
I get
org.hibernate.LazyInitializationException: failed to lazily initialize collections, failed to initialize proxies - without a session, with org.springframework.data.rest.webmvc.json.patch.JsonLateObjectEvaluator.evaluate (JsonLateObjectEvaluator.java:45)
, ? - , "" - Spring?
: , :
[
{
"op": "add",
"path": "/equipmentCodes",
"value": "https://localhost:8080/api/equipmentCodes/40529099"
}
]
, EquipmentCode 40529099 ElementType EquipmentCode (, https://localhost:8080/api/elementTypes/40529090), , ElementType
, EquipmentCode, , ElementType, EquipmentCodes .