📄 parameterpersistenceprovider.java
字号:
/*
* Copyright (C) 2002 Erik Swenson - eswenson@opensourcesoft.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package org.efs.openreports.providers.persistence;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.efs.openreports.objects.ReportParameter;
import org.efs.openreports.providers.ProviderException;
import org.efs.openreports.util.LocalStrings;
import net.sf.hibernate.*;
public class ParameterPersistenceProvider extends HibernateProvider
{
protected static Log log =
LogFactory.getLog(ParameterPersistenceProvider.class.getName());
public ParameterPersistenceProvider() throws ProviderException
{
super();
log.info("ParameterPersistenceProvider Created.");
}
public ReportParameter getReportParameter(Integer id)
throws ProviderException
{
return (ReportParameter) load(ReportParameter.class, id);
}
public ReportParameter getReportParameter(String name) throws ProviderException
{
try
{
Session session = openSession();
Transaction tx = null;
try
{
tx = session.beginTransaction();
List list =
session.find(
"from org.efs.openreports.objects.ReportParameter reportParameter "
+ "where reportParameter.name = ?",
name,
Hibernate.STRING);
if (list.size() == 0)
return null;
ReportParameter reportParameter = (ReportParameter) list.get(0);
tx.commit();
return reportParameter;
}
catch (HibernateException he)
{
if (tx != null)
tx.rollback();
throw he;
}
finally
{
session.close();
}
}
catch (HibernateException he)
{
throw new ProviderException(he);
}
}
public List getReportParameters() throws ProviderException
{
String fromClause =
"from org.efs.openreports.objects.ReportParameter reportParameter order by reportParameter.name ";
return query(fromClause);
}
public ReportParameter insertReportParameter(ReportParameter reportParameter)
throws ProviderException
{
return (ReportParameter) save(reportParameter);
}
public void updateReportParameter(ReportParameter reportParameter)
throws ProviderException
{
update(reportParameter);
}
public void deleteReportParameter(ReportParameter reportParameter)
throws ProviderException
{
try
{
delete(reportParameter);
}
catch (ConstraintException ce)
{
throw new ProviderException(LocalStrings.getString(LocalStrings.ERROR_PARAMETER_DELETION));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -