本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}