List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:com.sshdemo.common.security.manage.dao.UserDAO.java
@Override public void updatePassword(final String username, final String password) { String hql = "Update User o Set o.password=:password Where username=:username"; Query query = this.getEntityManager().createQuery(hql); query.setParameter("username", username); query.setParameter("password", password); query.executeUpdate();// w ww .ja v a 2 s. c o m }
From source file:springchat.test.MessagesServiceTest.java
@Test public void testPersistence() { List<MessageEntity> msgs = messages.getMessages(); final Long uid = messages.save(System.currentTimeMillis(), "botossauro", "Hi there!").getUid(); Assert.assertNotNull(uid);//from w ww. j ava2 s .c o m Assert.assertEquals("botossauro", eao.withQuery("SELECT e FROM MessageEntity e WHERE e.uid = :puid", new BaseEAO.ExecutableQuery<MessageEntity>() { @Override public MessageEntity execute(Query query) { query.setParameter("puid", uid); return (MessageEntity) query.getSingleResult(); } }).getUser()); Assert.assertTrue(messages.getMessages().size() == msgs.size() + 1); }
From source file:com.dhenton9000.birt.jpa.service.impl.OrdersServiceImpl.java
@Override public List<Orders> getOrdersForOffice(String officeCode) { String qString = "select orders " + " from Offices offices " + " join offices.employees employees " + " join employees.customers customers " + " join customers.orders orders " + " where offices.officeCode = :id "; Query q = this.entityManager.createQuery(qString); q.setParameter("id", officeCode); return q.getResultList(); }
From source file:com.gymadmin.persistence.dao.impl.UserDaoImpl.java
public UserEntity findByNick(String nick) { Query namedQuery = em.createNamedQuery("UserEntity.findByNick"); namedQuery.setParameter("nick", nick); try {/* w ww.ja v a 2 s .c o m*/ return (UserEntity) namedQuery.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:eu.domibus.common.dao.AttachmentDAO.java
public byte[] loadBinaryData(int entityId) { Query q = this.em.createNamedQuery("PartInfo.loadBinaryData"); q.setParameter("ENTITY_ID", entityId); return (byte[]) q.getSingleResult(); }
From source file:ispok.dao.LevelHibernateJpaDao.java
@Override @SuppressWarnings("unchecked") public Level get(int duration, int breakDuration, Long betsetId) { String jpql = "SELECT l FROM Level l WHERE l.duration = :duration AND l.breakDuration = :breakDuration AND l.betset.id = :betsetId"; Query query = getEntityManager().createQuery(jpql); query.setParameter("duration", duration); query.setParameter("breakDuration", breakDuration); query.setParameter("betsetId", betsetId); List<Level> l = query.getResultList(); if (l.isEmpty()) { return null; }/*from w ww . jav a 2 s. c om*/ return l.get(0); }
From source file:com.gymadmin.persistence.dao.impl.PaymentMethodDaoImpl.java
public PaymentPlanEntity findByName(String name) { Query namedQuery = em.createNamedQuery("PaymentMethodEntity.findByName"); namedQuery.setParameter("name", name); return (PaymentPlanEntity) namedQuery.getSingleResult(); }
From source file:com.gymadmin.persistence.dao.impl.PlanDaoImpl.java
public List<PlanEntity> findByFilters(Map<String, String> filters) { Query namedQuery = em.createNamedQuery("PlanEntity.findByFilters"); namedQuery.setParameter("name", "%" + filters.get("name").toUpperCase() + "%"); namedQuery.setParameter("description", "%" + filters.get("description").toUpperCase() + "%"); return (List<PlanEntity>) namedQuery.getResultList(); }
From source file:com.gymadmin.persistence.dao.impl.PlanDaoImpl.java
public PlanEntity findByName(String name) { Query namedQuery = em.createNamedQuery("PlanEntity.findByName"); namedQuery.setParameter("name", name); try {/* ww w.j ava 2 s. c o m*/ return (PlanEntity) namedQuery.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:jv.jpatpl.service.PersonService.java
@SuppressWarnings("unchecked") public List<Person> find(String name) { Query query = this.entityManager.createNamedQuery("Person.find"); query.setParameter("name", "%" + name + "%"); return query.getResultList(); }