01: package ru.emdev.EmForge.security.dao;
02:
03: import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
04:
05: /** User settings dao is responsible for working with UserSettings objects
06: *
07: */
08: public class UserSettingsDao extends HibernateDaoSupport {
09: public UserSettings getUserSettings(String i_userName) {
10: UserSettings userSettings = (UserSettings) getHibernateTemplate()
11: .get(UserSettings.class, i_userName);
12: if (userSettings == null) {
13: userSettings = new UserSettings();
14: userSettings.setUser(i_userName);
15:
16: saveUserSettings(userSettings);
17: }
18:
19: return userSettings;
20: }
21:
22: public void saveUserSettings(UserSettings i_userSettings) {
23: getHibernateTemplate().saveOrUpdate(i_userSettings);
24: getHibernateTemplate().flush();
25: }
26: }
|