spring input validation with put request
good day everyone,
i have this spring rest api that i'm building, and currently having a problem with the put method on my of controllers.
i have a question entity that has a relation with a test entity:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name="question_id", nullable = false, updatable = false)
private Long id;
@Column(name="question_text", nullable = false)
@NotNull
private String question;
@Column(name="question_weight", nullable = false)
@Min(1)
private Integer weight = 1;
@Column(name="question_type", nullable = false)
private String type = "radio";
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_modified", nullable = false)
@LastModifiedDate
private Date lastModified;
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = com.QCMGenerator.QCMGenerator.Model.Test.class)
@JoinColumn(name = "test_id", referencedColumnName = "test_id", nullable = false, updatable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Test test;
i posted earlier asking about this problem and i've been told to use the DTOs, so i did and here is my question DTO:
private Long id;
private String question;
private String type;
private Integer weight;
private Date lastModified;
private TestDTO test;
and this the put method i have in my controller:
@PutMapping("/{questionID}")
public QuestionDTO updateQuestion(
@PathVariable(value = "testID") Long testID,
@PathVariable(value = "questionID") Long questionID,
@Valid @RequestBody QuestionDTO newQuestion
){
if(!testRepo.existsById(testID)){
throw new ResourceNotFoundException("No test with the ID '"+testID+"' was found...");
}
QuestionDTO savedDTO = null;
try {
Question questionEntity = questionRepo.findById(questionID).get();
QuestionDTO questionDTO = convertToDTO(questionEntity);
if (newQuestion.getTest() != null) {
questionDTO.setTest(newQuestion.getTest());
}
if (newQuestion.getQuestion() != null) {
questionDTO.setQuestion(newQuestion.getQuestion());
}
if (newQuestion.getType() != null) {
questionDTO.setType(newQuestion.getType());
}
if (newQuestion.getWeight() != null) {
questionDTO.setWeight(newQuestion.getWeight());
}
Question newQuestionEntity = convertToEntity(questionDTO);
Question saved = questionRepo.save(newQuestionEntity);
savedDTO = convertToDTO(saved);
}catch (Exception e){
System.out.println(e.getMessage());
}
return savedDTO;
}
and i keep getting this error on my IDE console:
2018-11-18 21:33:12.249 WARN 12876 --- [nio-8080-exec-2] o.h.a.i.UnresolvedEntityInsertActions : HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
Unsaved transient entity: ([com.QCMGenerator.QCMGenerator.Model.Test#])
Dependent entities: ([[com.QCMGenerator.QCMGenerator.Model.Question#10]])
Non-nullable association(s): ([com.QCMGenerator.QCMGenerator.Model.Question.test])
org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test
i was hoping someone here would clarify this problem for me as i have been stuck all day long just on that single method or the other methods work fine, i have tried with and without a DTO and before adding it i was having a problem with the method accepting null values on certain fields.
i really appreciate any help given and thank you all for your help.
have a good day everyone. :D
spring hibernate rest spring-boot put
add a comment |
good day everyone,
i have this spring rest api that i'm building, and currently having a problem with the put method on my of controllers.
i have a question entity that has a relation with a test entity:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name="question_id", nullable = false, updatable = false)
private Long id;
@Column(name="question_text", nullable = false)
@NotNull
private String question;
@Column(name="question_weight", nullable = false)
@Min(1)
private Integer weight = 1;
@Column(name="question_type", nullable = false)
private String type = "radio";
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_modified", nullable = false)
@LastModifiedDate
private Date lastModified;
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = com.QCMGenerator.QCMGenerator.Model.Test.class)
@JoinColumn(name = "test_id", referencedColumnName = "test_id", nullable = false, updatable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Test test;
i posted earlier asking about this problem and i've been told to use the DTOs, so i did and here is my question DTO:
private Long id;
private String question;
private String type;
private Integer weight;
private Date lastModified;
private TestDTO test;
and this the put method i have in my controller:
@PutMapping("/{questionID}")
public QuestionDTO updateQuestion(
@PathVariable(value = "testID") Long testID,
@PathVariable(value = "questionID") Long questionID,
@Valid @RequestBody QuestionDTO newQuestion
){
if(!testRepo.existsById(testID)){
throw new ResourceNotFoundException("No test with the ID '"+testID+"' was found...");
}
QuestionDTO savedDTO = null;
try {
Question questionEntity = questionRepo.findById(questionID).get();
QuestionDTO questionDTO = convertToDTO(questionEntity);
if (newQuestion.getTest() != null) {
questionDTO.setTest(newQuestion.getTest());
}
if (newQuestion.getQuestion() != null) {
questionDTO.setQuestion(newQuestion.getQuestion());
}
if (newQuestion.getType() != null) {
questionDTO.setType(newQuestion.getType());
}
if (newQuestion.getWeight() != null) {
questionDTO.setWeight(newQuestion.getWeight());
}
Question newQuestionEntity = convertToEntity(questionDTO);
Question saved = questionRepo.save(newQuestionEntity);
savedDTO = convertToDTO(saved);
}catch (Exception e){
System.out.println(e.getMessage());
}
return savedDTO;
}
and i keep getting this error on my IDE console:
2018-11-18 21:33:12.249 WARN 12876 --- [nio-8080-exec-2] o.h.a.i.UnresolvedEntityInsertActions : HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
Unsaved transient entity: ([com.QCMGenerator.QCMGenerator.Model.Test#])
Dependent entities: ([[com.QCMGenerator.QCMGenerator.Model.Question#10]])
Non-nullable association(s): ([com.QCMGenerator.QCMGenerator.Model.Question.test])
org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test
i was hoping someone here would clarify this problem for me as i have been stuck all day long just on that single method or the other methods work fine, i have tried with and without a DTO and before adding it i was having a problem with the method accepting null values on certain fields.
i really appreciate any help given and thank you all for your help.
have a good day everyone. :D
spring hibernate rest spring-boot put
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49
add a comment |
good day everyone,
i have this spring rest api that i'm building, and currently having a problem with the put method on my of controllers.
i have a question entity that has a relation with a test entity:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name="question_id", nullable = false, updatable = false)
private Long id;
@Column(name="question_text", nullable = false)
@NotNull
private String question;
@Column(name="question_weight", nullable = false)
@Min(1)
private Integer weight = 1;
@Column(name="question_type", nullable = false)
private String type = "radio";
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_modified", nullable = false)
@LastModifiedDate
private Date lastModified;
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = com.QCMGenerator.QCMGenerator.Model.Test.class)
@JoinColumn(name = "test_id", referencedColumnName = "test_id", nullable = false, updatable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Test test;
i posted earlier asking about this problem and i've been told to use the DTOs, so i did and here is my question DTO:
private Long id;
private String question;
private String type;
private Integer weight;
private Date lastModified;
private TestDTO test;
and this the put method i have in my controller:
@PutMapping("/{questionID}")
public QuestionDTO updateQuestion(
@PathVariable(value = "testID") Long testID,
@PathVariable(value = "questionID") Long questionID,
@Valid @RequestBody QuestionDTO newQuestion
){
if(!testRepo.existsById(testID)){
throw new ResourceNotFoundException("No test with the ID '"+testID+"' was found...");
}
QuestionDTO savedDTO = null;
try {
Question questionEntity = questionRepo.findById(questionID).get();
QuestionDTO questionDTO = convertToDTO(questionEntity);
if (newQuestion.getTest() != null) {
questionDTO.setTest(newQuestion.getTest());
}
if (newQuestion.getQuestion() != null) {
questionDTO.setQuestion(newQuestion.getQuestion());
}
if (newQuestion.getType() != null) {
questionDTO.setType(newQuestion.getType());
}
if (newQuestion.getWeight() != null) {
questionDTO.setWeight(newQuestion.getWeight());
}
Question newQuestionEntity = convertToEntity(questionDTO);
Question saved = questionRepo.save(newQuestionEntity);
savedDTO = convertToDTO(saved);
}catch (Exception e){
System.out.println(e.getMessage());
}
return savedDTO;
}
and i keep getting this error on my IDE console:
2018-11-18 21:33:12.249 WARN 12876 --- [nio-8080-exec-2] o.h.a.i.UnresolvedEntityInsertActions : HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
Unsaved transient entity: ([com.QCMGenerator.QCMGenerator.Model.Test#])
Dependent entities: ([[com.QCMGenerator.QCMGenerator.Model.Question#10]])
Non-nullable association(s): ([com.QCMGenerator.QCMGenerator.Model.Question.test])
org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test
i was hoping someone here would clarify this problem for me as i have been stuck all day long just on that single method or the other methods work fine, i have tried with and without a DTO and before adding it i was having a problem with the method accepting null values on certain fields.
i really appreciate any help given and thank you all for your help.
have a good day everyone. :D
spring hibernate rest spring-boot put
good day everyone,
i have this spring rest api that i'm building, and currently having a problem with the put method on my of controllers.
i have a question entity that has a relation with a test entity:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name="question_id", nullable = false, updatable = false)
private Long id;
@Column(name="question_text", nullable = false)
@NotNull
private String question;
@Column(name="question_weight", nullable = false)
@Min(1)
private Integer weight = 1;
@Column(name="question_type", nullable = false)
private String type = "radio";
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_modified", nullable = false)
@LastModifiedDate
private Date lastModified;
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = com.QCMGenerator.QCMGenerator.Model.Test.class)
@JoinColumn(name = "test_id", referencedColumnName = "test_id", nullable = false, updatable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Test test;
i posted earlier asking about this problem and i've been told to use the DTOs, so i did and here is my question DTO:
private Long id;
private String question;
private String type;
private Integer weight;
private Date lastModified;
private TestDTO test;
and this the put method i have in my controller:
@PutMapping("/{questionID}")
public QuestionDTO updateQuestion(
@PathVariable(value = "testID") Long testID,
@PathVariable(value = "questionID") Long questionID,
@Valid @RequestBody QuestionDTO newQuestion
){
if(!testRepo.existsById(testID)){
throw new ResourceNotFoundException("No test with the ID '"+testID+"' was found...");
}
QuestionDTO savedDTO = null;
try {
Question questionEntity = questionRepo.findById(questionID).get();
QuestionDTO questionDTO = convertToDTO(questionEntity);
if (newQuestion.getTest() != null) {
questionDTO.setTest(newQuestion.getTest());
}
if (newQuestion.getQuestion() != null) {
questionDTO.setQuestion(newQuestion.getQuestion());
}
if (newQuestion.getType() != null) {
questionDTO.setType(newQuestion.getType());
}
if (newQuestion.getWeight() != null) {
questionDTO.setWeight(newQuestion.getWeight());
}
Question newQuestionEntity = convertToEntity(questionDTO);
Question saved = questionRepo.save(newQuestionEntity);
savedDTO = convertToDTO(saved);
}catch (Exception e){
System.out.println(e.getMessage());
}
return savedDTO;
}
and i keep getting this error on my IDE console:
2018-11-18 21:33:12.249 WARN 12876 --- [nio-8080-exec-2] o.h.a.i.UnresolvedEntityInsertActions : HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
Unsaved transient entity: ([com.QCMGenerator.QCMGenerator.Model.Test#])
Dependent entities: ([[com.QCMGenerator.QCMGenerator.Model.Question#10]])
Non-nullable association(s): ([com.QCMGenerator.QCMGenerator.Model.Question.test])
org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : com.QCMGenerator.QCMGenerator.Model.Question.test -> com.QCMGenerator.QCMGenerator.Model.Test
i was hoping someone here would clarify this problem for me as i have been stuck all day long just on that single method or the other methods work fine, i have tried with and without a DTO and before adding it i was having a problem with the method accepting null values on certain fields.
i really appreciate any help given and thank you all for your help.
have a good day everyone. :D
spring hibernate rest spring-boot put
spring hibernate rest spring-boot put
asked Nov 18 '18 at 20:40
chawki challadiachawki challadia
157
157
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49
add a comment |
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49
add a comment |
2 Answers
2
active
oldest
votes
This error occurs when you are trying to save an entity association with null id.
Means is this case convertToEntity method in
Question newQuestionEntity = convertToEntity(questionDTO);
returns questionEntity with new Test object.
you should check all relations inside an entity for being null when their id is null.
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
add a comment |
You need add ID in your entity in order to save an entity with that ID as reference.
Easy to solve it:
Question newQuestionEntity = convertToEntity(questionDTO);
newQuestionEntity.setId(testID);
A best solution would be:
questionDTO.setID(testID);
public Question convertToEntity(QuestionDTO qDto) {
Question question = new Question(qDto.getID()) ;
.......
return question;
}
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365236%2fspring-input-validation-with-put-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This error occurs when you are trying to save an entity association with null id.
Means is this case convertToEntity method in
Question newQuestionEntity = convertToEntity(questionDTO);
returns questionEntity with new Test object.
you should check all relations inside an entity for being null when their id is null.
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
add a comment |
This error occurs when you are trying to save an entity association with null id.
Means is this case convertToEntity method in
Question newQuestionEntity = convertToEntity(questionDTO);
returns questionEntity with new Test object.
you should check all relations inside an entity for being null when their id is null.
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
add a comment |
This error occurs when you are trying to save an entity association with null id.
Means is this case convertToEntity method in
Question newQuestionEntity = convertToEntity(questionDTO);
returns questionEntity with new Test object.
you should check all relations inside an entity for being null when their id is null.
This error occurs when you are trying to save an entity association with null id.
Means is this case convertToEntity method in
Question newQuestionEntity = convertToEntity(questionDTO);
returns questionEntity with new Test object.
you should check all relations inside an entity for being null when their id is null.
answered Nov 18 '18 at 21:22
MoodiMoodi
1098
1098
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
add a comment |
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
i'm sorry but i didn't understand how exactly i can solve this problem, can you please elaborate more ?
– chawki challadia
Nov 18 '18 at 21:52
add a comment |
You need add ID in your entity in order to save an entity with that ID as reference.
Easy to solve it:
Question newQuestionEntity = convertToEntity(questionDTO);
newQuestionEntity.setId(testID);
A best solution would be:
questionDTO.setID(testID);
public Question convertToEntity(QuestionDTO qDto) {
Question question = new Question(qDto.getID()) ;
.......
return question;
}
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
|
show 1 more comment
You need add ID in your entity in order to save an entity with that ID as reference.
Easy to solve it:
Question newQuestionEntity = convertToEntity(questionDTO);
newQuestionEntity.setId(testID);
A best solution would be:
questionDTO.setID(testID);
public Question convertToEntity(QuestionDTO qDto) {
Question question = new Question(qDto.getID()) ;
.......
return question;
}
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
|
show 1 more comment
You need add ID in your entity in order to save an entity with that ID as reference.
Easy to solve it:
Question newQuestionEntity = convertToEntity(questionDTO);
newQuestionEntity.setId(testID);
A best solution would be:
questionDTO.setID(testID);
public Question convertToEntity(QuestionDTO qDto) {
Question question = new Question(qDto.getID()) ;
.......
return question;
}
You need add ID in your entity in order to save an entity with that ID as reference.
Easy to solve it:
Question newQuestionEntity = convertToEntity(questionDTO);
newQuestionEntity.setId(testID);
A best solution would be:
questionDTO.setID(testID);
public Question convertToEntity(QuestionDTO qDto) {
Question question = new Question(qDto.getID()) ;
.......
return question;
}
answered Nov 19 '18 at 5:42
Jonathan JohxJonathan Johx
1,587217
1,587217
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
|
show 1 more comment
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
i didn't understand where the problem exactly ? is it the question entity or the test entity and which one i need to set the id of ?
– chawki challadia
Nov 19 '18 at 15:44
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
Your issue is that you aren't adding the entity ID before you save, when you update an element you need to add entity ID which will be updated.
– Jonathan Johx
Nov 19 '18 at 16:29
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
which id do i need to set ? the test id or the question id ? cuz i did try to set both and it didn't work
– chawki challadia
Nov 20 '18 at 17:14
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
never mind the problem is i didn't check for null fields
– chawki challadia
Nov 20 '18 at 17:47
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
could you share your code on some repo?
– Jonathan Johx
Nov 20 '18 at 23:33
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365236%2fspring-input-validation-with-put-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
try to debug the put request in eclipse and check the values
– Deadpool
Nov 18 '18 at 22:49