Index: src/main/java/com/wediscussmovies/project/model/Discussion.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Discussion.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/model/Discussion.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -1,10 +1,10 @@
 package com.wediscussmovies.project.model;
 
-import com.wediscussmovies.project.model.relation.DiscussionLikes;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
 
 import javax.persistence.*;
-import java.sql.Date;
-import java.util.List;
+import java.time.LocalDate;
 import java.util.Objects;
 
@@ -28,5 +28,5 @@
     @Basic
     @Column(name = "date")
-    private Date date;
+    private LocalDate date;
 
 
@@ -47,7 +47,7 @@
 
     @Transient
-    private Long likes;
+    private long likes;
 
-    public Discussion(Character type, String text, String title, Date date, User user) {
+    public Discussion(Character type, String text, String title, LocalDate date, User user) {
         this.type = type;
         this.text = text;
@@ -56,4 +56,6 @@
         this.user = user;
     }
+
+
 
     public Discussion() {
Index: src/main/java/com/wediscussmovies/project/model/Movie.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Movie.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/model/Movie.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -9,4 +9,5 @@
 
 import javax.persistence.*;
+import java.io.Serializable;
 import java.sql.Date;
 import java.util.Collection;
Index: src/main/java/com/wediscussmovies/project/model/Person.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Person.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/model/Person.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -7,4 +7,5 @@
 import javax.persistence.*;
 import javax.swing.text.DateFormatter;
+import java.io.Serializable;
 import java.sql.Date;
 import java.time.LocalDate;
Index: src/main/java/com/wediscussmovies/project/model/User.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/User.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/model/User.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -10,4 +10,5 @@
 
 import javax.persistence.*;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
Index: src/main/java/com/wediscussmovies/project/querymodels/DiscussionLikesQM.java
===================================================================
--- src/main/java/com/wediscussmovies/project/querymodels/DiscussionLikesQM.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/querymodels/DiscussionLikesQM.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -1,20 +1,22 @@
 package com.wediscussmovies.project.querymodels;
 
+import com.wediscussmovies.project.model.Movie;
+import com.wediscussmovies.project.model.Person;
+import com.wediscussmovies.project.model.User;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
+import java.time.LocalDate;
+import java.util.Date;
 import java.util.Objects;
 
 @Data
+@AllArgsConstructor
+@NoArgsConstructor
 public class DiscussionLikesQM {
+
     private Integer discussionId;
     private Long likes;
-
-    public DiscussionLikesQM(Integer discussionId, Long likes) {
-        this.discussionId = discussionId;
-        this.likes = likes;
-    }
-
-    public DiscussionLikesQM() {
-    }
 
     @Override
Index: src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java
===================================================================
--- src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -19,17 +19,17 @@
      List<Discussion> findAllByPerson (Person person);
 
-     @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM(d.discussionId, count(dl.id.userId)) from Discussion d" +
+     @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM(d.discussionId, count (dl.user) ) from Discussion d" +
              " left join DiscussionLikes dl on dl.id.discussionId = d.discussionId" +
-             " where :discussionId = d.discussionId" +
-             " group by d.discussionId"+
-             " order by count(dl.id.userId) desc")
+             " where :id = d.discussionId" +
+             " group by d.discussionId")
      @Transactional
-     DiscussionLikesQM findDiscussionWithLikes(@Param("discussionId") Integer discussionId);
+     DiscussionLikesQM findDiscussionWithLikes(@Param("id") Integer discussionId);
 
-     @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM(d.discussionId, count(dl.id.userId)) from Discussion d" +
+     @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM (d.discussionId, count(dl.user))  from Discussion d" +
              " left join DiscussionLikes dl on dl.id.discussionId = d.discussionId" +
              " group by d.discussionId"+
-             " order by count(dl.id.userId) desc")
+               " order by d.discussionId asc")
      @Transactional
-     List<DiscussionLikesQM> findAllDiscussionsWithLikes();
+     List<DiscussionLikesQM
+             > findAllDiscussionsWithLikes();
 }
Index: src/main/java/com/wediscussmovies/project/service/DiscussionService.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/DiscussionService.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/service/DiscussionService.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -22,5 +22,5 @@
     DiscussionLikesQM findLikesForDiscussionWithId(Integer discussionId);
 
-    void findLikesForAllDiscussions(List<Discussion> discussions);
+    List<DiscussionLikesQM> findLikesForAllDiscussions();
 
 }
Index: src/main/java/com/wediscussmovies/project/service/impl/DiscussionServiceImpl.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/impl/DiscussionServiceImpl.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/service/impl/DiscussionServiceImpl.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -16,8 +16,8 @@
 import org.springframework.stereotype.Service;
 
-import java.sql.Date;
 import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 @Service
@@ -45,10 +45,15 @@
     @Override
     public List<Discussion> listAll() {
-        return this.discussionRepository.findAll();
+        List<Discussion> discussions = this.discussionRepository.findAll();
+        List<DiscussionLikesQM> discussionLikes  = this.discussionRepository.findAllDiscussionsWithLikes();
+        for (int i = 0; i < discussionLikes.size(); i++){
+            discussions.get(i).setLikes(discussionLikes.get(i).getLikes());
+        }
+        return discussions;
     }
 
     @Override
     public void save(Character type,Integer id,String title, String text,User user) {
-        Date date = Date.valueOf(LocalDate.now());
+        LocalDate date = LocalDate.now();
         Discussion discussion;
 
@@ -123,9 +128,7 @@
 
     @Override
-    public void findLikesForAllDiscussions(List<Discussion> discussions) {
-//        this.discussionRepository.findAllDiscussionsWithLikes()
-//                .forEach(el ->{
-//                        if (discussions.)
-//                });
+    public List<DiscussionLikesQM> findLikesForAllDiscussions() {
+           // return this.discussionRepository.findAllDiscussionsWithLikes();
+        return this.discussionRepository.findAllDiscussionsWithLikes();
     }
 
@@ -145,5 +148,7 @@
     @Override
     public Discussion findById(Integer id) {
-        return discussionRepository.findById(id).orElseThrow(() -> new DiscussionNotExistException(id));
+        Discussion disc =  discussionRepository.findById(id).orElseThrow(() -> new DiscussionNotExistException(id));
+        disc.setLikes(this.discussionRepository.findDiscussionWithLikes(id).getLikes());
+        return disc;
     }
 
Index: src/main/java/com/wediscussmovies/project/web/controller/DiscussionController.java
===================================================================
--- src/main/java/com/wediscussmovies/project/web/controller/DiscussionController.java	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/java/com/wediscussmovies/project/web/controller/DiscussionController.java	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -45,10 +45,11 @@
 
          */
-        List<Discussion> discussions = discussionService.listAllByTitle(titleSearch);
+        //List<Discussion> discussions = discussionService.listAllByTitle(titleSearch);
+        List<Discussion> discussions = discussionService.listAll();
         model.addAttribute("discussions", discussions);
         model.addAttribute("contentTemplate", "discussionsList");
         model.addAttribute("user",LoggedUser.getLoggedUser());
         this.addModelPropertiesForUser(model);
-        this.addModelPropertiesLikes(model,null, discussions);
+       // this.addModelPropertiesLikes(model,null, discussions);
         return "template";
     }
@@ -63,5 +64,4 @@
         try {
             Discussion disc = discussionService.findById(id);
-            disc.setLikes(discussionService.findLikesForDiscussionWithId(disc.getDiscussionId()).getLikes());
             model.addAttribute("disc", disc);
             model.addAttribute("contentTemplate", "discussion");
@@ -185,14 +185,14 @@
         // ispagja kompliciran kod vaka, podobro da dodademe i svojstvo u diskusijata i koga ke se dodade lajk
         // soodvetno da se zgoleme i obratno
-        if(discussion==null){
-            List<DiscussionLikesQM> discussionLikes = new ArrayList<>();
-            for(Discussion d: discussions){
-                discussionLikes.add(discussionService.findLikesForDiscussionWithId(d.getDiscussionId()));
-            }
-            model.addAttribute("likes", discussionLikes);
-        }
-        else{
-            model.addAttribute("likes",discussionService.findLikesForDiscussionWithId(discussion.getDiscussionId()).getLikes());
-        }
+//        if(discussion==null){
+//            List<DiscussionLikesQM> discussionLikes = new ArrayList<>();
+//            for(Discussion d: discussions){
+//                discussionLikes.add(discussionService.findLikesForDiscussionWithId(d.getDiscussionId()));
+//            }
+//            model.addAttribute("likes", discussionLikes);
+//        }
+//        else{
+//            model.addAttribute("likes",discussionService.findLikesForDiscussionWithId(discussion.getDiscussionId()).getLikes());
+//        }
     }
 
Index: src/main/resources/templates/discussion.html
===================================================================
--- src/main/resources/templates/discussion.html	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/resources/templates/discussion.html	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -15,5 +15,5 @@
             </span>
             <span>Број на допаѓања:</span>
-            <span th:text="${likes}" id="likes_count"></span>
+            <span th:text="${disc.getLikes()}" id="likes_count"></span>
         </h4>
         <br>
Index: src/main/resources/templates/discussionsList.html
===================================================================
--- src/main/resources/templates/discussionsList.html	(revision 6f91f99177aa46ee208fa8328553bb98a196cc3a)
+++ src/main/resources/templates/discussionsList.html	(revision 8f1b7e9ff410a2892ccfe2af2277a9cae1881749)
@@ -31,5 +31,5 @@
                                 <a th:text="${disc.getTitle()}" th:href="@{'/discussions/{id}' (id=${disc.getDiscussionId()})}"></a>
                             </td>
-                            <td th:text="${disc.getLikes()}" class="likes_count">
+                            <td th:text="${disc.getLikes() != null ? disc.getLikes() : 0}"  class="likes_count">
                             </td>
                             <td th:text="${disc.getDate()}"></td>
