List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:com.trailmagic.image.hibernate.HibernateImageGroupRepository.java
License:Open Source License
public ImageGroup getRollByOwnerAndName(User owner, String rollName) { try {// w ww .j a v a 2 s .co m Session session = SessionFactoryUtils.getSession(sessionFactory, false); Query qry = session.getNamedQuery(ROLL_BY_OWNER_AND_NAME_QRY); qry.setEntity("owner", owner); qry.setString("rollName", rollName); qry.setCacheable(true); return (ImageGroup) qry.uniqueResult(); } catch (HibernateException e) { throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:com.trailmagic.image.hibernate.HibernateImageGroupRepository.java
License:Open Source License
public ImageGroup getByOwnerNameAndTypeWithFrames(User owner, String groupName, Type groupType) { try {/*from w w w . ja v a2s .c om*/ Session session = SessionFactoryUtils.getSession(sessionFactory, false); Query qry = session.getNamedQuery(GROUP_BY_OWNER_NAME_TYPE_QRY); qry.setEntity("owner", owner); qry.setString("groupName", groupName); qry.setString("groupType", groupType.toString()); qry.setCacheable(true); final ImageGroup group = (ImageGroup) qry.uniqueResult(); // join fetch stopped working after enabling caching? if (group != null && group.getFrames().size() > 0) { group.getFrames().first(); } return group; } catch (HibernateException e) { throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:com.trailmagic.image.hibernate.HibernateImageGroupRepository.java
License:Open Source License
public List<ImageGroup> getByImage(Image image) { try {//from w w w. j av a 2 s .co m Session session = SessionFactoryUtils.getSession(sessionFactory, false); Query qry = session.getNamedQuery(GROUPS_BY_IMAGE_QRY); qry.setEntity("image", image); qry.setCacheable(true); return qry.list(); } catch (HibernateException e) { throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:com.trailmagic.image.hibernate.HibernateImageGroupRepository.java
License:Open Source License
public ImageGroup getRollForImage(Image image) { // images should always only be in one roll try {/*from w w w.j a v a 2 s. c o m*/ Session session = SessionFactoryUtils.getSession(sessionFactory, false); Query qry = session.getNamedQuery(ROLL_FOR_IMAGE_QRY); qry.setEntity("image", image); qry.setCacheable(true); List results = qry.list(); if (results.size() < 1) { return null; } return (ImageGroup) results.get(0); } catch (HibernateException e) { throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:com.trailmagic.user.hibernate.HibernateGroupFactory.java
License:Open Source License
public List<Group> getForUser(final User user) { return (List<Group>) m_hibernateTemplate.execute(new HibernateCallback() { public Object doInHibernate(Session session) { Query qry = session.getNamedQuery(FOR_USER_QUERY); qry.setEntity("user", user); return qry.list(); }//from ww w. j a va 2s . c o m }); }
From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.ConversationParticipationDAOImpl.java
License:Open Source License
/** * @see com.tysanclan.site.projectewok.entities.dao.ConversationParticipationDAO#countUnreadMessages(com.tysanclan.site.projectewok.entities.User) *///from w w w. j a v a 2 s .c om @Override public long countUnreadMessages(User user) { StringBuilder builder = new StringBuilder(); builder.append( "SELECT COUNT(*) FROM ConversationParticipation cp WHERE cp.user = :user AND size(cp.readMessages) < (SELECT COUNT(*) FROM Message m, Conversation c WHERE c.id = cp.conversation AND m.conversation = c.id)"); Query query = getSession().createQuery(builder.toString()); query.setEntity("user", user); return (Long) query.uniqueResult(); }
From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.UnreadForumPostDAOImpl.java
License:Open Source License
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void markAsRead(User user, ForumPost post) { Query query = getSession() .createQuery("delete from UnreadForumPost where user = :reader and forumPost = :post"); query.setEntity("reader", user); query.setEntity("post", post); query.executeUpdate();// ww w . ja v a2 s .com }
From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.UserGameRealmDAOImpl.java
License:Open Source License
@Override public void removeUserGameRealmsByRealm(Realm realm) { Query query = getSession().createQuery("delete from UserGameRealm where realm = :realm"); query.setEntity("realm", realm); query.executeUpdate();//from w w w . j a v a 2 s . co m }
From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.UserGameRealmDAOImpl.java
License:Open Source License
@Override public void removeUserGameRealmsByGame(Game game) { Query query = getSession().createQuery("delete from UserGameRealm where game = :game"); query.setEntity("game", game); query.executeUpdate();/*www . ja va 2 s . co m*/ }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateAgentSynchronisationMessageDao.java
License:Apache License
public List<AgentSynchronisationMessage> findByAgentState(final AgentState agentState) { return getHibernateTemplate().execute(new HibernateCallback<List<AgentSynchronisationMessage>>() { public List<AgentSynchronisationMessage> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from AgentSynchronisationMessage where agentState = :agentState order by id asc"); queryObject.setEntity("agentState", agentState); return queryObject.list(); }/*from w ww . j a v a 2 s . co m*/ }); }