Skip to content
Snippets Groups Projects
Commit ff321697 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

implement get apps

parent 03970909
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ package org.hbp.mip.controllers;
import io.swagger.annotations.*;
import org.hbp.mip.model.App;
import org.hbp.mip.utils.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -32,6 +35,21 @@ public class AppsApi {
) {
List<App> apps = new LinkedList<>();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
try {
session.beginTransaction();
Query query = session.createQuery("FROM App");
apps = query.list();
session.getTransaction().commit();
} catch (Exception e)
{
if(session.getTransaction() != null)
{
session.getTransaction().rollback();
throw e;
}
}
return ResponseEntity.ok(apps);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment