Hej mam problem bo połączyłam tabele komentarzy z tabela postów i dostaje błąd
Hibernate:
select
post0_.postid as postid1_7_,
post0_.autor as autor2_7_,
post0_.opis as opis3_7_,
post0_.tytul as tytul4_7_
from
post post0_
where
post0_.postid=?
Hibernate:
select
comment0_.idComment as idCommen1_5_,
comment0_.autor as autor2_5_,
comment0_.opis as opis3_5_,
comment0_1_.idComment as idCommen1_6_
from
comment comment0_
left outer join
comment_post comment0_1_
on comment0_.idComment=comment0_1_.postid
kwi 16, 2018 1:48:54 PM org.springframework.web.servlet.tags.form.HiddenInputTag doStartTag
SEVERE: Invalid property 'idComment' of bean class [java.util.ArrayList]: Bean property 'idComment' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.NotReadablePropertyException: Invalid property 'idComment' of bean class [java.util.ArrayList]: Bean property 'idComment' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
w kontrolerze mam:
@RequestMapping(value="/posts/{postid}/comments")
@Controller
public class CommentController {
@RequestMapping(value = "", method = RequestMethod.GET)
public ModelAndView Comment(@PathVariable Long postid, ModelAndView model) {
List<Post> list = postService.getAllPosts(postid);
List<Comment> comment = commentService.getAllComment();
model.addObject("comment", comment);
model.addObject("list", list);
model.setViewName("view");
return model;
}
@RequestMapping(value = "/newComment", method = RequestMethod.GET)
public ModelAndView newComment(@PathVariable Long postid, @ModelAttribute("comment") Comment comment,
BindingResult result){
List<Post> list = postService.getAllPosts(postid);
Map<String, Object> model = new HashMap<String, Object>();
model.put("comment", commentService.getAllComment());
model.put("list", list);
return new ModelAndView("view", model);
}
@RequestMapping(value = "/saveComment", method = RequestMethod.POST)
public ModelAndView saveComment(@PathVariable Long postid, @ModelAttribute Comment comment) {
List<Post> list = postService.getAllPosts(postid);
commentService.saveOrUpdate(comment);
return new ModelAndView("redirect:/posts/{postid}/comments");
}
w .jsp
<div align="center">
<form:form action="saveComment" method="post" commandName="comment">
<form:hidden path="idComment"/>
<div class="form-group row">
<div class="col-xs-4">
<label for="ex3"></label>
<input class="form-control" name="autor" id="ex3" type="string" placeholder="Autor">
</div>
</div>
<div class="form-group row">
<div class="col-xs-4">
<label for="ex3"></label>
<input class="form-control" name="opis" id="ex3" type="string" placeholder="Opis">
</div>
</div>
<button type="submit" value="Save" class="btn btn-primary active">Dodaj</button>
</form:form>
</div>
<h2>${idComment}</h2>
<c:forEach var="post" items="${comment}">
<div class="container">
<div class="col-md-12">
<h1>${comment.autor }</h1>