2025年5月10日 星期六 農曆 乙巳年四月十四
 王朝网络
分享
 
 
 

项目要用到的主要源代码

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  举报/纠错

package com.laoer.base;

import java.io.Serializable;

import java.math.BigDecimal;

import java.sql.Timestamp;

import java.util.Calendar;

import java.util.Date;

import java.util.HashMap;

import java.util.Iterator;

import java.util.Map;

import org.springframework.orm.hibernate.support.HibernateDaoSupport;

import net.sf.hibernate.Criteria;

import net.sf.hibernate.HibernateException;

import net.sf.hibernate.Query;

import net.sf.hibernate.Session;

import net.sf.hibernate.Transaction;

import net.sf.hibernate.SessionFactory;

import net.sf.hibernate.cfg.Configuration;

import net.sf.hibernate.expression.Expression;

import net.sf.hibernate.expression.Order;

import net.sf.hibernate.type.Type;

/**

* This class has been automatically generated by Hibernate Synchronizer.

* For more information or documentation, visit The Hibernate Synchronizer page

* at http://www.binamics.com/hibernatesync or contact Joe Hudson at joe@binamics.com.

*/

public abstract class _BaseRootDAO extends HibernateDaoSupport{

protected static Map sessionFactoryMap = new HashMap();

protected static ThreadLocal threadedSessions = new ThreadLocal();

/**

* Configure the session factory by reading hibernate config file

*/

public static void initialize () throws HibernateException {

initialize((String) null);

}

/**

* Configure the session factory by reading hibernate config file

* @param configFileName the name of the configuration file

*/

public static void initialize (String configFileName) throws HibernateException {

if (null == configFileName && sessionFactoryMap.size() 0) return;

else if (null != sessionFactoryMap.get(configFileName)) return;

else {

Configuration cfg = new Configuration();

if (null == configFileName)

cfg.configure();

else

cfg.configure(configFileName);

setSessionFactory(configFileName, cfg.buildSessionFactory());

}

}

/**

* Set the session factory

*/

//protected static void setSessionFactory (SessionFactory sessionFactory) {

//setSessionFactory((String) null, sessionFactory);

//}

/**

* Set the session factory

*/

protected static void setSessionFactory (String configFileName, SessionFactory sessionFactory) {

sessionFactoryMap.put(configFileName, sessionFactory);

}

/**

* Return the SessionFactory that is to be used by these DAOs. Change this

* and implement your own strategy if you, for example, want to pull the SessionFactory

* from the JNDI tree.

*/

//protected SessionFactory getSessionFactory() throws HibernateException {

//return getSessionFactory (getConfigurationFileName());

//}

private static SessionFactory getSessionFactory(String configFile) throws HibernateException {

if (sessionFactoryMap.size() == 1) return (SessionFactory) sessionFactoryMap.values().toArray()[0];

else {

SessionFactory sessionFactory = (SessionFactory) sessionFactoryMap.get(configFile);

if (null == sessionFactory)

if (null == configFile)

throw new RuntimeException("The session factory has not been initialized.");

else

throw new RuntimeException("The session factory for '" + configFile + "' has not been initialized.");

else

return sessionFactory;

}

}

/**

* Return a new Session object that must be closed when the work has been completed.

* @return the active Session

*/

//protected Session getSession() throws HibernateException {

//return createSession();

//}

/**

* Return a new Session object that must be closed when the work has been completed.

* @return the active Session

*/

public static Session createSession() throws HibernateException {

return createSession(null);

}

/**

* Return a new Session object that must be closed when the work has been completed.

* @param configFile the config file must match the meta attribute "config-file" in the hibernate mapping file

* @return the active Session

*/

public static Session createSession(String configFile) throws HibernateException {

java.util.Stack sessionStack = (java.util.Stack) threadedSessions.get();

Session session = null;

if (null == sessionStack) {

sessionStack = new java.util.Stack();

threadedSessions.set(sessionStack);

}

if (sessionStack.size() 0) {

Object[] arr = (Object[]) sessionStack.peek();

String cf = (String) arr[0];

if (null == cf) {

session = (Session) arr[1];

}

else if (null != cf && null != configFile) {

if (cf.equals(configFile)) session = (Session) arr[1];

}

if (null == session) {

session = getSessionFactory(configFile).openSession();

arr = new Object[2];

arr[0] = configFile;

arr[1] = session;

sessionStack.push(arr);

}

}

else {

session = getSessionFactory(configFile).openSession();

Object[] arr = new Object[2];

arr = new Object[2];

arr[0] = configFile;

arr[1] = session;

sessionStack.push(arr);

}

return session;

}

/**

* Return the name of the configuration file to be used with this DAO or null if default

*/

public String getConfigurationFileName () {

return null;

}

/**

* Return the specific Object class that will be used for class-specific

* implementation of this DAO.

* @return the reference Class

*/

protected abstract Class getReferenceClass();

/**

* Close the session

*/

public void closeSession () throws HibernateException {

java.util.Stack sessionStack = (java.util.Stack) threadedSessions.get();

if (null != sessionStack) {

Object[] arr = (Object[]) sessionStack.peek();

String cf = (String) arr[0];

if (null == cf) {

Session session = (Session) arr[1];

session.close();

sessionStack.pop();

}

else {

String configurationFile = getConfigurationFileName();

if (null != configurationFile && configurationFile.equals(cf)) {

Session session = (Session) arr[1];

session.close();

sessionStack.pop();

}

}

}

}

/**

* Begin the transaction related to the session

*/

public Transaction beginTransaction(Session s) throws HibernateException {

return s.beginTransaction();

}

/**

* Commit the given transaction

*/

public void commitTransaction(Transaction t) throws HibernateException {

t.commit();

}

/**

* Execute a query.

* @param query a query expressed in Hibernate's query language

* @return a distinct list of instances (or arrays of instances)

*/

public java.util.List find(String query) throws HibernateException {

Session s = null;

try {

s = getSession();

return find(query, s);

} finally {

closeSession();

}

}

/**

* Perform a find but use the session given instead of creating a new one.

* @param query a query expressed in Hibernate's query language

* @s the Session to use

*/

public java.util.List find(String query, Session s) throws HibernateException {

return s.find(query);

}

/**

* Return all objects related to the implementation of this DAO with no filter.

*/

public java.util.List findAll () throws HibernateException {

Session s = null;

try {

s = getSession();

return findAll(s);

}

finally {

closeSession();

}

}

/**

* Return all objects related to the implementation of this DAO with no filter.

* Use the session given.

* @param s the Session

*/

public java.util.List findAll (Session s) throws HibernateException {

return findAll(s, getDefaultOrderProperty());

}

/**

* Return all objects related to the implementation of this DAO with no filter.

*/

public java.util.List findAll (String orderProperty) throws HibernateException {

Session s = null;

try {

s = getSession();

return findAll(s, orderProperty);

}

finally {

closeSession();

}

}

/**

* Return all objects related to the implementation of this DAO with no filter.

* Use the session given.

* @param s the Session

*/

public java.util.List findAll (Session s, String orderProperty) throws HibernateException {

Criteria crit = createCriteria(s);

if (null != orderProperty) crit.addOrder(Order.asc(orderProperty));

return crit.list();

}

/**

* Return all objects related to the implementation of this DAO with a filter.

* Use the session given.

* @param propName the name of the property to use for filtering

* @param filter the value of the filter

*/

protected java.util.List findFiltered (String propName, Object filter) throws HibernateException {

return findFiltered(propName, filter, getDefaultOrderProperty());

}

/**

* Return all objects related to the implementation of this DAO with a filter.

* Use the session given.

* @param propName the name of the property to use for filtering

* @param filter the value of the filter

* @param orderProperty the name of the property used for ordering

*/

protected java.util.List findFiltered (String propName, Object filter, String orderProperty) throws HibernateException {

Session s = null;

try {

s = getSession();

return findFiltered(s, propName, filter, getDefaultOrderProperty());

}

finally {

closeSession();

}

}

/**

* Return all objects related to the implementation of this DAO with a filter.

* Use the session given.

* @param s the Session

* @param propName the name of the property to use for filtering

* @param filter the value of the filter

* @param orderProperty the name of the property used for ordering

*/

protected java.util.List findFiltered (Session s, String propName, Object filter, String orderProperty) throws HibernateException {

Criteria crit = createCriteria(s);

crit.add(Expression.eq(propName, filter));

if (null != orderProperty) crit.addOrder(Order.asc(orderProperty));

return crit.list();

}

/**

* Obtain an instance of Query for a named query string defined in the mapping file.

* @param name the name of a query defined externally

* @return Query

*/

public java.util.List getNamedQuery(String name) throws HibernateException {

Session s = null;

try {

s = getSession();

return getNamedQuery(name, s);

} finally {

closeSession();

}

}

/**

* Obtain an instance of Query for a named query string defined in the mapping file.

* Use the session given.

* @param name the name of a query defined externally

* @param s the Session

* @return Query

*/

public java.util.List getNamedQuery(String name, Session s) throws HibernateException {

Query q = s.getNamedQuery(name);

return q.list();

}

/**

* Obtain an instance of Query for a named query string defined in the mapping file.

* Use the parameters given.

* @param name the name of a query defined externally

* @param params the parameter array

* @return Query

*/

public java.util.List getNamedQuery(String name, Serializable[] params)

throws HibernateException {

Session s = null;

try {

s = getSession();

return getNamedQuery(name, params, s);

} finally {

closeSession();

}

}

/**

* Obtain an instance of Query for a named query string defined in the mapping file.

* Use the parameters given and the Session given.

* @param name the name of a query defined externally

* @param params the parameter array

* @s the Session

* @return Query

*/

public java.util.List getNamedQuery(String name, Serializable[] params, Session s)

throws HibernateException {

Query q = s.getNamedQuery(name);

if (null != params) {

for (int i = 0; i

* where a database trigger alters the object state upon insert or update

* after executing direct SQL (eg. a mass update) in the same session

* after inserting a Blob or Clob

*

*/

public void refresh (com.laoer.EbGoods ebGoods, Session s)

throws net.sf.hibernate.HibernateException {

super.refresh(ebGoods, s);

}

public String getDefaultOrderProperty () {

return null;

}

}

以上是一个具体实现根类的代码,自动生成的。

/*

* Created on 2005-1-8

*

* TODO To change the template for this generated file go to

* Window - Preferences - Java - Code Style - Code Templates

*/

package com.laoer.base;

import net.sf.hibernate.HibernateException;

import net.sf.hibernate.Session;

import com.laoer.EbClass;

/**

* @author Administrator

*

* TODO To change the template for this generated type comment go to

* Window - Preferences - Java - Code Style - Code Templates

*/

public interface IBaseEbClassDAO {

/**

* com.laoer.dao._RootDAO _RootDAO.getReferenceClass()

*/

public Class getReferenceClass();

public com.laoer.EbClass load(java.lang.String key)

throws net.sf.hibernate.HibernateException;

public com.laoer.EbClass load(java.lang.String key, Session s)

throws net.sf.hibernate.HibernateException;

public com.laoer.EbClass loadInitialize(java.lang.String key, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Persist the given transient instance, first assigning a generated identifier. (Or using the current value

* of the identifier property if the assigned generator is used.)

* @param ebClass a transient instance of a persistent class

* @return the class identifier

*/

public java.lang.String save(com.laoer.EbClass ebClass)

throws net.sf.hibernate.HibernateException;

/**

* Persist the given transient instance, first assigning a generated identifier. (Or using the current value

* of the identifier property if the assigned generator is used.)

* Use the Session given.

* @param ebClass a transient instance of a persistent class

* @param s the Session

* @return the class identifier

*/

public java.lang.String save(com.laoer.EbClass ebClass, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Either save() or update() the given instance, depending upon the value of its identifier property. By default

* the instance is always saved. This behaviour may be adjusted by specifying an unsaved-value attribute of the

* identifier property mapping.

* @param ebClass a transient instance containing new or updated state

*/

public void saveOrUpdate(com.laoer.EbClass ebClass)

throws net.sf.hibernate.HibernateException;

/**

* Either save() or update() the given instance, depending upon the value of its identifier property. By default the

* instance is always saved. This behaviour may be adjusted by specifying an unsaved-value attribute of the identifier

* property mapping.

* Use the Session given.

* @param ebClass a transient instance containing new or updated state.

* @param s the Session.

*/

public void saveOrUpdate(com.laoer.EbClass ebClass, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent

* instance with the same identifier in the current session.

* @param ebClass a transient instance containing updated state

*/

public void update(com.laoer.EbClass ebClass)

throws net.sf.hibernate.HibernateException;

/**

* Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent

* instance with the same identifier in the current session.

* Use the Session given.

* @param ebClass a transient instance containing updated state

* @param the Session

*/

public void update(com.laoer.EbClass ebClass, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving

* Session or a transient instance with an identifier associated with existing persistent state.

* @param id the instance ID to be removed

*/

public void delete(java.lang.String id)

throws net.sf.hibernate.HibernateException;

/**

* Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving

* Session or a transient instance with an identifier associated with existing persistent state.

* Use the Session given.

* @param id the instance ID to be removed

* @param s the Session

*/

public void delete(java.lang.String id, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving

* Session or a transient instance with an identifier associated with existing persistent state.

* @param ebClass the instance to be removed

*/

public void delete(com.laoer.EbClass ebClass)

throws net.sf.hibernate.HibernateException;

/**

* Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving

* Session or a transient instance with an identifier associated with existing persistent state.

* Use the Session given.

* @param ebClass the instance to be removed

* @param s the Session

*/

public void delete(com.laoer.EbClass ebClass, Session s)

throws net.sf.hibernate.HibernateException;

/**

* Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement

* long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.

* For example

*

* where a database trigger alters the object state upon insert or update

* after executing direct SQL (eg. a mass update) in the same session

* after inserting a Blob or Clob

*

*/

public void refresh(com.laoer.EbClass ebClass, Session s)

throws net.sf.hibernate.HibernateException;

public String getDefaultOrderProperty();

}

是eclipse重构出来的接口。(为spring用的)

qq:39459358

举报/纠错
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005-2025 王朝網路 版權所有 聯絡我們