Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow excluding properties from being nullified in PUT requests [DATAREST-873] #1243

Closed
spring-projects-issues opened this issue Aug 16, 2016 · 3 comments
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Aug 16, 2016

Nestor Fedyk opened DATAREST-873 and commented

Hi guys, I ran into strange issue with spring-data-rest. I have two columns being updated by @CreatedDate and @LastModifiedDate annotations. When I submit update PUT request without createdAt property specified in the body, it gets nullified in DB. Is this the expected behavior?
I have the following entity structure

@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name="Items")
public class Item implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="itemId")
    private int itemId;

    @Column(name="itemName")
    private String itemName;

    @Column(name="CreatedAt")
    @CreatedDate
    private Date createdAt;

    @Column(name="ModifiedAt")
    @LastModifiedDate
    private Date modifiedAt;
}

Affects: 2.4.4 (Gosling SR4), 2.5.2 (Hopper SR2), 2.6 M1 (Ingalls)

Backported to: 2.5.3 (Hopper SR3), 2.4.5 (Gosling SR5)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2016

Oliver Drotbohm commented

Generally speaking, yes. PUT requires the resource identified by the URI the request is sent to to be replaced with what the client sends. So unless you take dedicated action on the server side to tweak those semantics. Spring Data REST already does so for properties that are better reflected through dedicated means HTTP exposes for their technical purpose: database identifiers are removed from the representation as HTTP defines URIs to be the primary means for identification. We also remove the last modified property from the representation as there's a standard header for that.

I just tried to use @ReadOnlyProperty on a class structured like yours and it looks like the component handling the application of JSON payloads to domain objects but it seems it currently doesn't have any effect. I guess that should be fixed here

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2016

Oliver Drotbohm commented

That's in place now. Feel free to give the snapshots a try

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2016

Nestor Fedyk commented

Thanks for quick fix. Do you have anticipated release date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

2 participants