View Javadoc

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  	/* (non-Javadoc)
16  	 * @see hu.elte.tribus.util.idx.IdxDao#deleteIndexFile(hu.elte.tribus.util.idx.IndexFile)
17  	 */
18  	public void deleteIndexFile(IndexFile file) {
19  		getSession().delete(file);
20  	}
21  
22  	/* (non-Javadoc)
23  	 * @see hu.elte.tribus.util.idx.IdxDao#deleteIndexFile(java.lang.String)
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  	/* (non-Javadoc)
32  	 * @see hu.elte.tribus.util.idx.IdxDao#getIndexFile(java.lang.String)
33  	 */
34  	public IndexFile getIndexFile(String name) {
35  		return (IndexFile) getSession().load(IndexFile.class, name);
36  	}
37  
38  	/* (non-Javadoc)
39  	 * @see hu.elte.tribus.util.idx.IdxDao#saveIndexFile(hu.elte.tribus.util.idx.IndexFile)
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  }