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


Java Session.load方法代码示例

本文整理汇总了Java中org.hibernate.Session.load方法的典型用法代码示例。如果您正苦于以下问题:Java Session.load方法的具体用法?Java Session.load怎么用?Java Session.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Session的用法示例。


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

示例1: changeGranted

import org.hibernate.Session; //导入方法依赖的package包/类
@Expose
public void changeGranted(Collection<Map<String, Object>> members)
		throws Exception {
	getLoginUser();
	Session session = this.getSessionFactory().openSession();
	try {
		for (Map<String, Object> map : members) {
			RoleMember rm = (RoleMember) session.load(RoleMember.class,
					(String) map.get("memberId"));
			rm.setGranted((Boolean) map.get("granted"));
			session.update(rm);
		}
	} finally {
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:18,代码来源:RoleMemberMaintain.java

示例2: listEmailsOfEvent

import org.hibernate.Session; //导入方法依赖的package包/类
public List<String> listEmailsOfEvent(Long eventId) {
	Session session = sessionFactory.getCurrentSession();
	session.beginTransaction();

	List<String> emailList = new ArrayList<String>();
	Event event = session.load(Event.class, eventId);
	for (Iterator<Person> it = event.getParticipants().iterator(); it.hasNext(); ) {
		Person person = it.next();
		emailList.addAll(person.getEmailAddresses());
	}

	session.getTransaction().commit();
	return emailList;
}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:15,代码来源:EventManager.java

示例3: addPersonToAccount

import org.hibernate.Session; //导入方法依赖的package包/类
public Long addPersonToAccount(Long personId, Account account) {
	Session session = sessionFactory.getCurrentSession();
	session.beginTransaction();

	Person aPerson = session.load(Person.class, personId);
	account.setPerson(aPerson);

	Long accountId = (Long)session.save(account);

	session.getTransaction().commit();
	return accountId;
}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:13,代码来源:EventManager.java

示例4: getAccount

import org.hibernate.Session; //导入方法依赖的package包/类
public Account getAccount(Long accountId) {
	Session session = sessionFactory.getCurrentSession();
	session.beginTransaction();

	Account account = session.load(Account.class, accountId);

	session.getTransaction().commit();
	return account;
}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:10,代码来源:EventManager.java

示例5: addPhoneNumberToPerson

import org.hibernate.Session; //导入方法依赖的package包/类
public void addPhoneNumberToPerson(Long personId, PhoneNumber pN) {

		Session session = sessionFactory.getCurrentSession();
		session.beginTransaction();

		Person aPerson = session.load(Person.class, personId);
		pN.setPersonId(personId.longValue());
		aPerson.getPhoneNumbers().add(pN);

		session.getTransaction().commit();
	}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:12,代码来源:EventManager.java

示例6: load

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * 根据实体类id加载实体类
 * 
 * @param <T> 要加载的实体类
 * 
 * @param clazz 要加载的实体类
 * @param id 实体类id
 * 
 * @return 查询到的实体类的代理对象(记录不存则返回null)
 */
public final static <T extends BaseRelationalDatabaseDomain> T load(Class<T> clazz,Serializable id){
	try {
		Session session = getSession();
		return session.load(clazz, id);
	} catch (Exception e) {
		setException(e);
		return null;
	}finally{
		closeSession();
	}
}
 
开发者ID:battlesteed,项目名称:hibernateMaster,代码行数:22,代码来源:DaoUtil.java

示例7: load

import org.hibernate.Session; //导入方法依赖的package包/类
public void load(Object obj, Serializable srlzbl) {
    final Session ses = getTxManager().getSessionFactory().openSession();
    try {
        ses.load(obj, srlzbl);
    } finally {
        ses.close();
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:9,代码来源:Spring.java

示例8: changeGranted

import org.hibernate.Session; //导入方法依赖的package包/类
@Expose
public void changeGranted(Collection<Map<String,Object>> members) throws Exception{
	Session session=this.getSessionFactory().openSession();
	try{
		for(Map<String,Object> map:members){
			RoleMember rm=(RoleMember)session.load(RoleMember.class,(String)map.get("memberId"));
			rm.setGranted((Boolean)map.get("granted"));
			session.update(rm);
		}			
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:RoleMemberMaintain.java

示例9: getBookById

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public Book getBookById(int bookId) {
	Session session = sessionFactory.getCurrentSession();
	Book book = (Book) session.load(Book.class, bookId);
	return book;
}
 
开发者ID:zhangjikai,项目名称:sdudoc,代码行数:7,代码来源:BookDaoImpl.java

示例10: load

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * Used by the base DAO classes but here for your modification
 * Load object matching the given key and return it.
 */
@SuppressWarnings("unchecked")
protected T load(Class<T> refClass, K key, Session s) {
	return (T)s.load(refClass, key);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:9,代码来源:_BaseRootDAO.java

示例11: loadEntry

import org.hibernate.Session; //导入方法依赖的package包/类
protected HibernateProcessInstance loadEntry(Session session, final long piid) throws WorkflowStoreException {

        HibernateProcessInstance workflowEntry = (HibernateProcessInstance)session.load(HibernateProcessInstance.class, piid);
        
        // The next line forces the ORM to load the properties into the object; This should not be lazy loading
        //  but seems to be occuring; Access any property loads them all.  Work-around?

        workflowEntry.getState();
        return workflowEntry;
    }
 
开发者ID:will-gilbert,项目名称:OSWf-OSWorkflow-fork,代码行数:11,代码来源:HibernateStore.java

示例12: delete

import org.hibernate.Session; //导入方法依赖的package包/类
public boolean delete(Long id) throws SQLException {
	boolean isDelete = false;

	Session session = HibernateUtil.getSessionFactory().openSession();

	try {
		session.beginTransaction();

		T entity = (T) session.load(getEntityClass(), id);
		session.delete(entity);

		// This makes the pending delete to be done
		session.getTransaction().commit();

		isDelete = true;

	} catch (HibernateException hibernateException) {
		session.getTransaction().rollback();

		throw new SQLException(hibernateException);

	} finally {
		session.close();
	}

	return isDelete;
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:28,代码来源:GenericDao.java

示例13: addPersonToEvent

import org.hibernate.Session; //导入方法依赖的package包/类
public void addPersonToEvent(Long personId, Long eventId) {

		Session session = sessionFactory.getCurrentSession();
		session.beginTransaction();

		Person aPerson = session.load(Person.class, personId);
		Event anEvent = session.load(Event.class, eventId);

		aPerson.getEvents().add(anEvent);

		session.getTransaction().commit();
	}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:13,代码来源:EventManager.java

示例14: addEmailToPerson

import org.hibernate.Session; //导入方法依赖的package包/类
public void addEmailToPerson(Long personId, String emailAddress) {

		Session session = sessionFactory.getCurrentSession();
		session.beginTransaction();

		Person aPerson = session.load(Person.class, personId);

		// The getEmailAddresses() might trigger a lazy load of the collection
		aPerson.getEmailAddresses().add(emailAddress);

		session.getTransaction().commit();
	}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:13,代码来源:EventManager.java

示例15: addTalismanToPerson

import org.hibernate.Session; //导入方法依赖的package包/类
public void addTalismanToPerson(Long personId, String talisman) {

		Session session = sessionFactory.getCurrentSession();
		session.beginTransaction();

		Person aPerson = session.load(Person.class, personId);
		aPerson.addTalisman(talisman);

		session.getTransaction().commit();
	}
 
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:11,代码来源:EventManager.java


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