package com.hida.dao;

import com.hida.model.Setting;
import com.hida.model.TokenType;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * missing javadoc
 *
 * @author lruffin
 */
@Service("settingDao")
@Transactional
public class SettingDaoImpl extends AbstractDao<Integer, Setting> implements SettingDao {

    /**
     * missing javadoc
     *
     * @param setting
     */
    @Override
    public void save(Setting setting) {
        persist(setting);
    }

    /**
     * missing javadoc
     *
     * @param setting
     */
    @Override
    public void deleteSetting(Setting setting) {
        delete(setting);
    }

    /**
     * missing javadoc
     *
     * @return
     */
    @Override
    public List<Setting> findAllSettings() {
        Criteria criteria = createEntityCriteria();
        return (List<Setting>) criteria.list();
    }

    /**
     * missing javadoc
     *
     * @param id
     * @return
     */
    @Override
    public Setting findSettingById(int id) {
        Criteria criteria = createEntityCriteria();
        criteria.add(Restrictions.eq("id", id));
        return (Setting) criteria.uniqueResult();
    }

    /**
     * missing javadoc
     *
     * @param Prefix
     * @param TokenType
     * @param CharMap
     * @param RootLength
     * @param SansVowels
     * @return
     */
    @Override
    public List<Setting> findSetting(String Prefix, TokenType TokenType, String CharMap,
            int RootLength, boolean SansVowels) {
        Query query = this.getSession().createSQLQuery(
                String.format("Select from USED_SETTING where prefix='%s' and tokenType='%s' "
                        + "and charmap='%s' and rootlength='%d' and sansvowels='%b'",
                        Prefix, TokenType, CharMap, RootLength, SansVowels));

        return query.list();
    }
        

}

@@ -38,23 +38,25 @@
 a.model.
-Setting
+TokenType
 ;%0Aimport
@@ -67,33 +67,35 @@
 .hida.model.
-TokenType
+UsedSetting
 ;%0Aimport jav
@@ -211,16 +211,66 @@
 ctions;%0A
+import org.springframework.stereotype.Repository;%0A
 import o
@@ -428,44 +428,36 @@
 */%0A@
-Service(%22settingDao%22)%0A@Transactional
+Repository(%22usedSettingDao%22)
 %0Apub
@@ -466,16 +466,20 @@
 c class 
+Used
 SettingD
@@ -514,16 +514,20 @@
 nteger, 
+Used
 Setting%3E
@@ -538,16 +538,20 @@
 lements 
+Used
 SettingD
@@ -659,16 +659,20 @@
 id save(
+Used
 Setting 
@@ -827,16 +827,20 @@
 Setting(
+Used
 Setting 
@@ -965,32 +965,36 @@
     public List%3C
+Used
 Setting%3E findAll
@@ -993,16 +993,20 @@
  findAll
+Used
 Settings
@@ -1079,24 +1079,28 @@
 eturn (List%3C
+Used
 Setting%3E) cr
@@ -1224,16 +1224,20 @@
  public 
+Used
 Setting 
@@ -1236,24 +1236,28 @@
 Setting find
+Used
 SettingById(
@@ -1383,16 +1383,20 @@
 return (
+Used
 Setting)
@@ -1636,16 +1636,20 @@
 ic List%3C
+Used
 Setting%3E
@@ -1653,16 +1653,20 @@
 ng%3E find
+Used
 Setting(
@@ -2117,16 +2117,21 @@
 );%0A    %7D
+%0A%0A   
 %0A       

Replace Setting import for UsedSetting import