Project

General

Profile

1
package eu.dnetlib.goldoa.service.dao;
2

    
3
import eu.dnetlib.goldoa.domain.Help;
4
import org.hibernate.criterion.Restrictions;
5
import org.springframework.stereotype.Repository;
6

    
7
import java.util.List;
8

    
9
/*
10
 * Created by antleb on 4/17/15.
11
*/
12
@Repository
13
public class HelpDAO extends  AbstractDao<String,Help>{
14

    
15
//	private final static String UPDATE_HELP = "update help set name=?, text=? where id=?";
16
//	private final static String INSERT_HELP = "insert into help (name, text, id) values (?, ?, ?)";
17
//	private final static String GET_BY_ID = "select id, name, text from help where id = ?";
18
//	private final static String GET_ALL = "select id, name, text from help";
19
//	private final static String DELETE = "delete from help where id = ?";
20

    
21

    
22
	public Help saveHelp(Help help) {
23
		getSession().merge(help);
24
		return help;
25
	}
26

    
27
	public Help getById(String id) {
28
		List res = createEntityCriteria().add(Restrictions.eq("id", id)).list();
29

    
30
		if (!res.isEmpty())
31
        	return (Help) res.get(0);
32
		else
33
			return null;
34
    }
35
    @SuppressWarnings("unchecked")
36
	public List<Help> getAll() {
37
        return createEntityCriteria().list();
38
    }
39

    
40
	public void delete(String helpId) {
41
	    delete(getById(helpId));
42
	}
43
}
(4-4/12)