org.tinygroup.dao.hibernate.HibernateBaseDao Maven / Gradle / Ivy
/**
* Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
*
* Licensed under the GPL, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.gnu.org/licenses/gpl.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.tinygroup.dao.hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.tinygroup.dao.query.PagingObject;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
public abstract class HibernateBaseDao extends HibernateDaoSupport {
// 这里的返回值,可以直接返回getHibernateTemplate().save(entity)的值,这个会返回新插入记录的键值,也可以如下方式,返回一个持久化到数据库的对象
public Object save(Object entity) throws Exception {
getHibernateTemplate().save(entity);
return entity;
}
public Object update(Object entity) throws Exception {
getHibernateTemplate().update(entity);
return entity;
}
// delete返回的是一个空值,因为记录都删除了,就不会有键值或对象的返回
public void delete(Object entity) throws Exception {
getHibernateTemplate().delete(entity);
}
public List getObjectList(String queryString, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy