Skip to content

PATCH for non-resource associations doesn't work as expected [DATAREST-931] #1294

Closed
@spring-projects-issues

Description

@spring-projects-issues

Destan Sarpkaya opened DATAREST-931 and commented

User has a repository and Phone has not. [id and some other fields are pruned in below examples for brevity, see full entities in example code]

@Entity
public class User {

        private String name;

	@Column(nullable = false)
	@Temporal(value = TemporalType.TIMESTAMP)
	private Calendar creationDate;

	@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
	private List<Phone> phones;
}

@Entity
public class Phone extends BaseEntity {

	@Column(nullable = false)
	@Temporal(value = TemporalType.TIMESTAMP)
	private Calendar creationDate;

	@ManyToOne(fetch = FetchType.EAGER)
	private User user;
}

In this case patch for /users/1 with following data works:

{
   "name":"John Doe X",
   "phones":[
      {
         "id":1,
         "creationDate":"2016-11-02T07:34:02.806+0000",
         "label":"work",
         "number":"00000000"
      }
   ]
}

but following data fails with not-null-constraint error for creationDate:

{
   "name":"John Doe X",
   "phones":[
      {
         "id":1,
         "label":"work",
         "number":"00000000"
      }
   ]
}

PATCH works selectively on resources however doesn't work as expected for inline data which is not a resource (in this case "phone")


Affects: 2.5.4 (Hopper SR4)

Attachments:

Backported to: 2.5.5 (Hopper SR5), 2.4.7 (Gosling SR7)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions