1 16 package com.blandware.atleap.persistence.hibernate.core; 17 18 import com.blandware.atleap.common.util.PartialCollection; 19 import com.blandware.atleap.common.util.QueryInfo; 20 import com.blandware.atleap.model.core.ContentLocale; 21 import com.blandware.atleap.persistence.core.ContentLocaleDAO; 22 23 import java.util.ArrayList ; 24 import java.util.List ; 25 26 34 public class ContentLocaleDAOHibernate extends BaseDAOHibernate implements ContentLocaleDAO { 35 36 39 public ContentLocaleDAOHibernate() { 40 } 41 42 45 public void createContentLocale(ContentLocale contentLocale) { 46 getHibernateTemplate().save(contentLocale); 47 } 48 49 52 public ContentLocale retrieveContentLocale(String localeIdentifier) { 53 return (ContentLocale) getHibernateTemplate().get(ContentLocale.class, localeIdentifier); 54 } 55 56 59 public void updateContentLocale(ContentLocale contentLocale) { 60 getHibernateTemplate().update(contentLocale); 61 } 62 63 66 public void deleteContentLocale(ContentLocale contentLocale) { 67 getHibernateTemplate().delete(contentLocale); 68 } 69 70 73 public PartialCollection listContentLocales(QueryInfo queryInfo) { 74 String whereClause = new String (); 75 String orderByClause = new String (); 76 if ( queryInfo != null ) { 77 whereClause = queryInfo.getWhereClause(); 78 orderByClause = queryInfo.getOrderByClause(); 79 if ( whereClause != null && whereClause.length() != 0 ) { 80 whereClause = " where " + whereClause; 81 } else { 82 whereClause = new String (); 83 } 84 if ( orderByClause != null && orderByClause.length() != 0 ) { 85 orderByClause = " order by " + orderByClause; 86 } else { 87 orderByClause = " order by l.identifier"; 88 } 89 } 90 91 List list = null; 92 Integer total = null; 93 String hqlPart = "from ContentLocale l" + whereClause; 94 if ( queryInfo != null && (queryInfo.getLimit() != null || queryInfo.getOffset() != null) ) { 95 String hqlForTotal = "select count(l.identifier) " + hqlPart; 96 total = (Integer ) findUniqueResult(hqlForTotal); 97 if ( total == null ) { 98 total = new Integer (0); 99 } 100 } 101 if ( total == null || total.intValue() > 0 ) { 104 String hql = "select l " + hqlPart + orderByClause; 105 list = executeFind(hql, queryInfo); 106 if ( total == null ) { 107 total = new Integer (list.size()); 108 } 109 } else { 110 list = new ArrayList (); 111 } 112 return new PartialCollection(list, total); 113 } 114 115 118 public ContentLocale findDefaultContentLocale() { 119 return (ContentLocale) findUniqueResult("from ContentLocale l where l.defaultInstance = 'T'", true, "query.findDefaultContentLocale"); 120 } 121 122 } 123 | Popular Tags |