本文整理汇总了Java中javax.persistence.Query.getResultList方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getResultList方法的具体用法?Java Query.getResultList怎么用?Java Query.getResultList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.Query
的用法示例。
在下文中一共展示了Query.getResultList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findRecentRegionFrom
import javax.persistence.Query; //导入方法依赖的package包/类
@GET
@Produces({"application/xml", "application/json"})
@Path("/recent/region/{regionName}/{orderLineId}")
public List<LiveSalesList> findRecentRegionFrom(@PathParam("regionName") String regionName, @PathParam("orderLineId") Integer orderLineId) {
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
javax.persistence.criteria.CriteriaQuery cq = cb.createQuery();
Root<LiveSalesList> liveSalesList = cq.from(LiveSalesList.class);
cq.select(liveSalesList);
cq.where(cb.and(
cb.equal(liveSalesList.get(LiveSalesList_.region), regionName),
cb.gt(liveSalesList.get(LiveSalesList_.orderLineId), orderLineId)
));
Query q = getEntityManager().createQuery(cq);
q.setMaxResults(500);
return q.getResultList();
}
示例2: findPersonaEntities
import javax.persistence.Query; //导入方法依赖的package包/类
private List<Usuario> findPersonaEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(Usuario.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
示例3: getAllIXSICarStations
import javax.persistence.Query; //导入方法依赖的package包/类
@Override
@Transactional
public List<MBPlaceEntity> getAllIXSICarStations() {
log.debug("getting IXSI car sharing stations.");
Query q = entityManager.createNativeQuery(SELECTION, MBPlaceEntity.class)
.setParameter("clazz", CAR);
List<MBPlaceEntity> places = q.getResultList();
return places;
}
示例4: findRecent
import javax.persistence.Query; //导入方法依赖的package包/类
@GET
@Produces({"application/xml", "application/json"})
@Path("/recent/")
public List<LiveSalesList> findRecent() {
javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
cq.select(cq.from(LiveSalesList.class));
Query q = getEntityManager().createQuery(cq);
q.setMaxResults(500);
return q.getResultList();
}
示例5: listarVeiculos
import javax.persistence.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<Veiculo> listarVeiculos(){
Query query = em.createNamedQuery("Veiculo.findAll");
return query.getResultList();
}
示例6: countYesterdayCardsByPopulationCrous
import javax.persistence.Query; //导入方法依赖的package包/类
public static List<Object[]> countYesterdayCardsByPopulationCrous(String isMonday, String typeDate) {
EntityManager em = User.entityManager();
String mondayorNot = " AND to_date(to_char(" + typeDate + ", 'DD-MM-YYYY'), 'DD-MM-YYYY')= TIMESTAMP 'yesterday'";
if("true".equals(isMonday)){
mondayorNot = " AND to_char(" + typeDate + ", 'DD-MM-YYYY') = to_char((now() - interval '3 day'), 'DD-MM-YYYY')";
}
String sql = "SELECT cnous_reference_statut AS eppa, count(*) as count "
+ "FROM card, user_account WHERE card.user_account=user_account.id "
+ mondayorNot + " GROUP BY cnous_reference_statut";
Query q = em.createNativeQuery(sql);
return q.getResultList();
}
示例7: getAllProxyConfigurationSettings
import javax.persistence.Query; //导入方法依赖的package包/类
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public HashMap<String, Setting> getAllProxyConfigurationSettings()
throws ConfigurationException {
LOGGER.debug("Retrieving all configuration settings for proxy");
HashMap<String, Setting> result = new HashMap<>();
Query query = em.createNamedQuery("ConfigurationSetting.getAllProxy");
List<?> resultList = query.getResultList();
for (Object entry : resultList) {
ConfigurationSetting currentCs = (ConfigurationSetting) entry;
result.put(currentCs.getSettingKey(), new Setting(
currentCs.getSettingKey(), currentCs.getDecryptedValue()));
}
PlatformConfigurationKey[] keys = PlatformConfigurationKey.values();
StringBuffer missing = new StringBuffer();
for (int i = 0; i < keys.length; i++) {
if (keys[i].isMandatory() && !result.containsKey(keys[i].name())) {
if (missing.length() > 0) {
missing.append(", ");
}
missing.append(keys[i].name());
}
}
if (missing.length() > 0) {
throw new ConfigurationException(
"The configuration is missing the following parameter(s): "
+ missing.toString(),
missing.toString());
}
return result;
}
示例8: getUnresolvedGuestFeedback
import javax.persistence.Query; //导入方法依赖的package包/类
/**
* @return All guest feedback reports from the database that are not yet marked resolved.
*/
public List<GuestFeedback> getUnresolvedGuestFeedback() {
String query = "FROM GuestFeedback WHERE isResolved = :param";
Query q = entityManager.createQuery(query);
q.setParameter("param", false);
return q.getResultList();
}
示例9: getGroup
import javax.persistence.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public JpaGroup getGroup(final String name) throws NotFoundException {
final Query query = entityManager.createQuery("SELECT g FROM JpaGroup g WHERE lower(g.name) = lower(:groupName)");
query.setParameter("groupName", name);
List<JpaGroup> jpaGroups = query.getResultList();
if (jpaGroups == null || jpaGroups.isEmpty()) {
LOGGER.error("Error getting the group {}", name);
throw new NotFoundException(FaultType.GROUP_NOT_FOUND, "Group not found: " + name);
}
return jpaGroups.get(0);
}
示例10: findInactiveOnBehalfUsers
import javax.persistence.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<OnBehalfUserReference> findInactiveOnBehalfUsers(
Long lowerPeriodBound) {
Query query = dm.createNamedQuery(
"OnBehalfUserReference.findInactiveBeforePeriod");
query.setParameter("leastPermittedTime", lowerPeriodBound);
return query.getResultList();
}
示例11: read
import javax.persistence.Query; //导入方法依赖的package包/类
public List<Object> read() {
Query query = manager
.createQuery("SELECT ped "
+ "FROM Pedido ped "
+ "ORDER BY ped.created_at DESC");
@SuppressWarnings("unchecked")
List<Object> pedidos = query.getResultList();
return pedidos;
}
示例12: countNbRejetsByMonth
import javax.persistence.Query; //导入方法依赖的package包/类
public static List<Object> countNbRejetsByMonth(String userType) {
String sql = "SELECT to_char(date_etat, 'MM-YYYY') tochar, count(*) FROM card WHERE etat='REJECTED' GROUP BY tochar ORDER BY to_date(to_char(date_etat, 'MM-YYYY'), 'MM-YYYY')";
if (!userType.isEmpty()) {
sql = "SELECT to_char(date_etat, 'MM-YYYY') tochar, count(*) FROM card, user_account WHERE card.user_account= user_account.id " + "AND etat='REJECTED' AND user_type = :userType GROUP BY tochar ORDER BY to_date(to_char(date_etat, 'MM-YYYY'), 'MM-YYYY')";
}
EntityManager em = Card.entityManager();
Query q = em.createNativeQuery(sql);
if (!userType.isEmpty()) {
q.setParameter("userType", userType);
}
return q.getResultList();
}
示例13: Pedidos_por_semana
import javax.persistence.Query; //导入方法依赖的package包/类
public List<Pedido> Pedidos_por_semana() {
// Escreve a SQL
Query query = manager
.createQuery("SELECT COUNT(ped.id_pedido) as count, ped.data_pedido "
+ "FROM Pedido as ped "
+ "WHERE ped.data_pedido BETWEEN CURRENT_DATE -7 AND CURRENT_DATE "
+ "GROUP BY ped.data_pedido "
+ "ORDER BY ped.data_pedido");
@SuppressWarnings("unchecked")
List<Pedido> pedidos = query.getResultList();
return pedidos;
}
示例14: for
import javax.persistence.Query; //导入方法依赖的package包/类
private void SİLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SİLActionPerformed
// TODO add your handling code here:
//SİLME
EntityManagerFactory emf = Persistence.createEntityManagerFactory("BP2_LAB2PU");
EntityManager em = emf.createEntityManager();
Query q = em.createQuery("DELETE FROM Hasta h WHERE h.id=:id");
q.setParameter("id", tbl_hastalar.getValueAt(tbl_hastalar.getSelectedRow(), 0));
em.getTransaction().begin();
q.executeUpdate();
em.getTransaction().commit();
//
// SELECT
dtm.setRowCount(0);
q = em.createQuery("SELECT h FROM Hasta h");
List<Hasta> hastalar = q.getResultList();
for (Hasta hs : hastalar) {
dtm.addRow(new Object[]{hs.getId(), hs.getAdi(), hs.getSoyadi(), hs.getIdDoktor()});
}
tbl_hastalar.setModel(dtm);
//7
}
示例15: queryByNativeSQL
import javax.persistence.Query; //导入方法依赖的package包/类
/**
* 执行原生SQL查询
* @param sql
* @param params sql参数
* @return 结果集并影射成Map
*/
public List<Map<String,Object>> queryByNativeSQL(String sql,Map<String,Object> params){
Query query=em.createNativeQuery(sql);
if(params!=null&¶ms.size()>0){
for(String param:params.keySet() ){
query.setParameter(param,params.get(param));
}
}
query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
return query.getResultList();
}