1   /***
2    * 
3    */
4   package hu.elte.tribus.util.idx;
5   
6   import org.hibernate.Query;
7   import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
8   
9   /***
10   * @author kocka
11   *
12   */
13  public class HibernateIdxDao extends HibernateDaoSupport implements IdxDao {
14  
15  	
16  
17  
18  	public void deleteIndexFile(IndexFile file) {
19  		getSession().delete(file);
20  	}
21  
22  	
23  
24  
25  	public void deleteIndexFile(String name) {
26  		Query query = getSession().createQuery("delete from "+IndexFile.class.getName()+" where name=:nm");
27  		query.setString("nm", name);
28  		query.executeUpdate();
29  	}
30  
31  	
32  
33  
34  	public IndexFile getIndexFile(String name) {
35  		return (IndexFile) getSession().load(IndexFile.class, name);
36  	}
37  
38  	
39  
40  
41  	public void saveIndexFile(IndexFile file) {
42  		getSession().save(file);
43  	}
44  
45  	public boolean fileExists(String name) {
46  		IndexFile file = getIndexFile(name);
47  		return file != null;
48  	}
49  
50  }