当前位置: 首页>>代码示例>>Java>>正文


Java HibernateCallback类代码示例

本文整理汇总了Java中org.springframework.orm.hibernate3.HibernateCallback的典型用法代码示例。如果您正苦于以下问题:Java HibernateCallback类的具体用法?Java HibernateCallback怎么用?Java HibernateCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HibernateCallback类属于org.springframework.orm.hibernate3包,在下文中一共展示了HibernateCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scrollNotDeleted

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@SuppressWarnings ("unchecked")
public List<User> scrollNotDeleted (final int skip, final int top)
{
   // FIXME never call
   return getHibernateTemplate ().execute (
         new HibernateCallback<List<User>> ()
         {
            @Override
            public List<User> doInHibernate (Session session)
                  throws HibernateException, SQLException
            {
               String hql =
                     "FROM User WHERE deleted = false AND not username = " +
                           "'" +
                           cfgManager.getAdministratorConfiguration ()
                                 .getName () +
                           " AND not username = '" +
                           getPublicData ().getUsername () + "'" +
                           " ORDER BY username";
               Query query = session.createQuery (hql).setReadOnly (true);
               query.setFirstResult (skip);
               query.setMaxResults (top);
               return (List<User>) query.list ();
            }
         });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:27,代码来源:UserDao.java

示例2: getReasonCounts

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.MANDATORY)
public Map<String, Integer> getReasonCounts(final String user, final String attemptId)
{
	return (Map<String, Integer>) getHibernateTemplate().execute(new HibernateCallback()
	{
		@Override
		public Object doInHibernate(Session session) throws HibernateException, SQLException
		{
			Query query = session.createQuery("select count(reason), reason from Notification "
				+ "where attemptId = :attempt and processed = false "
				+ "and userTo = :user and institution = :inst group by reason");
			query.setParameter(ATTEMPT, attemptId);
			query.setParameter(USER, user);
			query.setParameter(INST, CurrentInstitution.get());
			Map<String, Integer> reasonMap = Maps.newHashMap();
			List<Object[]> counts = query.list();
			for( Object[] count : counts )
			{
				reasonMap.put((String) count[1], ((Number) count[0]).intValue());
			}
			return reasonMap;
		}
	});
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:NotificationDaoImpl.java

示例3: delete

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@Override
public void delete (final FileScanner scanner)
{
   getHibernateTemplate ().execute (new HibernateCallback<Void>()
   {
      @Override
      public Void doInHibernate (Session session) throws HibernateException,
         SQLException
      {
         String sql = "DELETE FROM FILE_SCANNER_PREFERENCES " +
            "WHERE FILE_SCANNER_ID = ?";
         SQLQuery query = session.createSQLQuery (sql);
         query.setLong (0, scanner.getId ());
         query.executeUpdate ();
         return null;
      }
   });
   super.delete (scanner);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:20,代码来源:FileScannerDao.java

示例4: optimize

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
public static void optimize ()
{
   HibernateDaoLocalSupport support = ApplicationContextProvider.getBean (
         HibernateDaoLocalSupport.class);
   support.getHibernateTemplate ().flush ();
   support.getHibernateTemplate ().executeWithNativeSession (
      new HibernateCallback<Void> ()
      {
         @Override
         public Void doInHibernate (Session session) throws
               HibernateException, SQLException
         {
            SQLQuery query = session.createSQLQuery ("CHECKPOINT DEFRAG");
            query.executeUpdate ();
            return null;
         }
      });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:DaoUtils.java

示例5: countOpenSessions

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@SuppressWarnings ("rawtypes")
private int countOpenSessions ()
{
   return DataAccessUtils.intResult (getHibernateTemplate ().execute (
      new HibernateCallback<List>()
      {
         @Override
         public List doInHibernate(Session session) 
            throws HibernateException, SQLException
         {
            String sql = 
               "SELECT count (*) FROM INFORMATION_SCHEMA.SYSTEM_SESSIONS";
            SQLQuery query = session.createSQLQuery (sql);
            return query.list ();
         }
      }));
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:18,代码来源:HibernateDao.java

示例6: getSystemByName

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@SuppressWarnings ({ "unchecked", "rawtypes" })
private String getSystemByName (final String name, final int index)
{
   return DataAccessUtils.uniqueResult (getHibernateTemplate ().execute (
      new HibernateCallback<List>()
      {
         @Override
         public List doInHibernate(Session session) 
            throws HibernateException, SQLException
         {
            String sql = 
               "SELECT " + name +
               " FROM INFORMATION_SCHEMA.SYSTEM_SESSIONS" +
               " LIMIT  1 OFFSET " + index;
            SQLQuery query = session.createSQLQuery (sql);
            return query.list ();
         }
      })).toString ();
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:20,代码来源:HibernateDao.java

示例7: getPage

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
/**
 * Returns a paged list of database entities.
 * 
 * @param query the passed query to retrieve the list.
 * @param skip the number of elements to skip in the list (0=no skip).
 * @param top number of element to be retained in the list.
 * @throws ClassCastException if query does not returns entity list of type T.
 * @see org.hibernate.Query
 */
@Override
public List<T> getPage (final String query, final int skip, final int top)
{
   return getHibernateTemplate ().execute (new HibernateCallback<List<T>> ()
   {
      // List must be instance of List<T> otherwise ClassCast
      @SuppressWarnings ("unchecked")
      @Override
      public List<T> doInHibernate (Session session) throws
            HibernateException, SQLException
      {
         Query hql_query = session.createQuery (query);
         hql_query.setFirstResult (skip);
         hql_query.setMaxResults (top);
         return hql_query.list ();
      }
   });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:28,代码来源:HibernateDao.java

示例8: deleteProductReferences

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
/**
 * Removes all the references of one product from all the existing carts.
 * @param product the product to be removed from carts.
 */
public void deleteProductReferences(final Product product)
{
   getHibernateTemplate().execute  (
      new HibernateCallback<Void>()
      {
         public Void doInHibernate(Session session) 
            throws HibernateException, SQLException
         {
            session.createSQLQuery(
               "DELETE FROM CART_PRODUCTS p " +
               " WHERE p.PRODUCT_ID = :pid").
               setParameter ("pid", product.getId()).executeUpdate ();
            return null;
         }
      });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:21,代码来源:ProductCartDao.java

示例9: getKeyBySubValue

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
/**
 * Retrieves a key from a KeyStore by a substring of its associated value.
 * @param sub_value substring of associate value
 * @return the key of searched value
 */
public String getKeyBySubValue(final String sub_value)
{
   return getHibernateTemplate().execute(new HibernateCallback<String>()
   {
      @Override
      public String doInHibernate(Session session) throws HibernateException, SQLException
      {
         Criteria criteria = session.createCriteria(entityClass);
         criteria.add(Restrictions.like("value", "%" + sub_value + "%"));
         List results = criteria.list();
         if (results.isEmpty())
         {
            return null;
         }
         return ((KeyStoreEntry) results.get(0)).getEntryKey();
      }
   });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:24,代码来源:KeyStoreEntryDao.java

示例10: deleteUnindexedById

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@Override
@Transactional(propagation = Propagation.MANDATORY)
public int deleteUnindexedById(final String user, final Collection<Long> notifications, final String attemptId)
{
	if( notifications.isEmpty() )
	{
		return 0;
	}
	return (Integer) getHibernateTemplate().execute(new HibernateCallback()
	{
		@Override
		public Object doInHibernate(Session session)
		{
			Query query = session.createQuery(
					"delete from Notification " + "where institution = :inst and userTo = :user and processed = false "
							+ "and id in (:noteid) and attemptId = :attempt");

			query.setParameter(ATTEMPT, attemptId);
			query.setParameterList(NOTEID, notifications);
			query.setParameter(USER, user);
			query.setParameter(INST, CurrentInstitution.get());
			return query.executeUpdate();
		}
	});
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:NotificationDaoImpl.java

示例11: getDownloadedSizeByUserSince

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
public long getDownloadedSizeByUserSince (final User user, final Date date)
{
   Long result =
         getHibernateTemplate ().execute (new HibernateCallback<Long> ()
         {
            @Override
            public Long doInHibernate (Session session)
                  throws HibernateException, SQLException
            {
               Criteria criteria = session.createCriteria (
                     NetworkUsage.class);
               criteria.setProjection (Projections.sum ("size"));
               criteria.add (Restrictions.eq ("isDownload", true));
               criteria.add (Restrictions.eq ("user", user));
               criteria.add (Restrictions.gt ("date", date));
               return (Long) criteria.uniqueResult ();
            }
         });
   return (result == null) ? 0 : result;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:21,代码来源:NetworkUsageDao.java

示例12: scrollSearchesOfUser

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
public List<Search> scrollSearchesOfUser (final User user, final int skip,
   final int top)
{
   return getHibernateTemplate ().execute (
      new HibernateCallback<List<Search>> ()
      {
         @Override
         @SuppressWarnings ("unchecked")
         public List<Search> doInHibernate (Session session)
            throws HibernateException, SQLException
         {
            String hql =
               "SELECT s FROM User u LEFT OUTER JOIN u.preferences p "
                  + "LEFT OUTER JOIN p.searches s "
                  + "WHERE u.uuid like ? ORDER BY s.value";
            Query query = session.createQuery (hql).setReadOnly (true);
            query.setString (0, user.getUUID ());
            query.setFirstResult (skip);
            query.setMaxResults (top);
            return (List<Search>) query.list ();
         }
      });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:24,代码来源:SearchDao.java

示例13: delete

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@Override
public void delete (final Search search)
{
   getHibernateTemplate ().execute (new HibernateCallback<Void>()
   {
      @Override
      public Void doInHibernate (Session session) throws HibernateException,
         SQLException
      {
         String sql = "DELETE FROM SEARCH_PREFERENCES WHERE SEARCHES_UUID = ?";
         Query query = session.createSQLQuery (sql);
         query.setString (0, search.getUUID ());
         query.executeUpdate ();
         return null;
      }
   });
   super.delete (search);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:SearchDao.java

示例14: scrollUploadedProducts

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
public List<Product> scrollUploadedProducts (final User user, final int skip,
   final int top)
{
   checkProductNumber(top);
   return getHibernateTemplate ().execute (
         new HibernateCallback<List<Product>>()
   {
      @Override
      @SuppressWarnings ("unchecked")
      public List<Product> doInHibernate (Session session)
         throws HibernateException, SQLException
      {
         String hql = "SELECT p FROM Product p, User u" +
                  " WHERE p.owner = u and u.uuid like ? AND p.processed = true";
         Query query = session.createQuery (hql);
         query.setString (0, user.getUUID ());
         query.setFirstResult (skip);
         query.setMaxResults (top);
         return (List<Product>) query.list ();
      }
   });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:23,代码来源:ProductDao.java

示例15: deleteAll

import org.springframework.orm.hibernate3.HibernateCallback; //导入依赖的package包/类
@Override
public void deleteAll ()
{
   getHibernateTemplate ().execute (new HibernateCallback<Void> ()
   {
      @Override
      public Void doInHibernate (Session session)
            throws HibernateException, SQLException
      {
         SQLQuery query =
               session.createSQLQuery ("DELETE FROM USER_RESTRICTIONS");
         query.executeUpdate ();
         query = session.createSQLQuery ("DELETE  FROM ACCESS_RESTRICTION");
         query.executeUpdate ();
         return null;
      }
   });
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:AccessRestrictionDao.java


注:本文中的org.springframework.orm.hibernate3.HibernateCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。