本文整理了Java中org.hibernate.classic.Session.createQuery()
方法的一些代码示例,展示了Session.createQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.createQuery()
方法的具体详情如下:
包路径:org.hibernate.classic.Session
类名称:Session
方法名:createQuery
暂无
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
sessionFactory.getCurrentSession().createQuery("DELETE FROM VersionInfo").executeUpdate();
}
});
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
sessionFactory.getCurrentSession().createQuery("DELETE FROM " + Plugin.class.getSimpleName()).executeUpdate();
}
});
代码示例来源:origin: gocd/gocd
@Override
public List<Plugin> getAllPlugins() {
return (List<Plugin>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Query query = sessionFactory.getCurrentSession().createQuery("FROM " + Plugin.class.getSimpleName());
query.setCacheable(true);
return query.list();
});
}
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
clearEnabledUserCountFromCache();
}
});
sessionFactory.getCurrentSession().createQuery("DELETE FROM User").executeUpdate();
}
});
代码示例来源:origin: gocd/gocd
public Users allUsers() {
return new Users((List<User>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Query query = sessionFactory.getCurrentSession().createQuery("FROM User");
query.setCacheable(true);
return query.list();
}));
}
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
clearEnabledUserCountFromCache();
}
});
String queryString = String.format("update %s set enabled = :enabled where name in (:userNames)", User.class.getName());
Query query = sessionFactory.getCurrentSession().createQuery(queryString);
query.setParameter("enabled", enabled);
query.setParameterList("userNames", usernames);
query.executeUpdate();
}
});
代码示例来源:origin: gocd/gocd
@Override
public boolean deleteUsers(List<String> userNames) {
return (Boolean) transactionTemplate.execute((TransactionCallback) status -> {
String queryString = "delete from User where name in (:userNames)";
Query query = sessionFactory.getCurrentSession().createQuery(queryString);
query.setParameterList("userNames", userNames);
query.executeUpdate();
return Boolean.TRUE;
});
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<Survey> retrieveAll() {
return sessionFactory.getCurrentSession()
.createQuery("from Survey survey order by survey.name").list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<Application> retrieveAll() {
return sessionFactory.getCurrentSession()
.createQuery("from Application app order by app.name").list();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@SuppressWarnings("unchecked")
public List<Customer> getCustomers() {
List<Customer> list = sessionFactory.getCurrentSession().createQuery("from Customer").list();
return list;
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@SuppressWarnings("unchecked")
public Set<String> getCustomerIds() {
List<String> customerIdList = sessionFactory
.getCurrentSession()
.createQuery("select cus.id from Customer cus")
.list();
return new HashSet<String>(customerIdList);
}
代码示例来源:origin: denimgroup/threadfix
@SuppressWarnings("unchecked")
@Override
public List<JobStatus> retrieveAllOpen() {
return sessionFactory
.getCurrentSession()
.createQuery(
"from JobStatus jobStatus where jobStatus.open = :open "
+ "order by jobStatus.modifiedDate desc").setBoolean("open", true)
.list();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@Transactional(readOnly = false)
public void deleteCustomer(String id) {
Query query = sessionFactory.getCurrentSession().createQuery("delete Customer where id=:id");
query.setParameter("id", id);
query.executeUpdate();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void resetHiddenAll() {
sessionFactory.getCurrentSession().createQuery(
"update Vulnerability vulnerability set hidden = false")
.executeUpdate();
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<Application> retrieveAllActiveFilter(Set<Integer> authenticatedTeamIds) {
return sessionFactory.getCurrentSession()
.createQuery("from Application app where app.active = true and app.organization.id in (:ids) order by app.name")
.setParameterList("ids", authenticatedTeamIds)
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<ExceptionLog> retrievePage(int page, int numberToShow) {
return sessionFactory.getCurrentSession()
.createQuery("from ExceptionLog log order by log.time desc")
.setMaxResults(numberToShow)
.setFirstResult((page - 1) * numberToShow)
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public Defect retrieveByNativeId(String nativeId) {
return (Defect) sessionFactory.getCurrentSession()
.createQuery("from Defect defect where defect.nativeId = :nativeId")
.setString("nativeId", nativeId).uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public SurveyResult retrieveByName(String name) {
return (SurveyResult) sessionFactory.getCurrentSession()
.createQuery("from SurveyResult surveyResult where surveyResult.name = :name")
.setString("name", name).uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public WafRule retrieveByRule(String rule) {
return (WafRule) sessionFactory.getCurrentSession()
.createQuery("from WafRule wafRule where wafRule.rule = :rule")
.setString("rule", rule).uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public Survey retrieveByName(String name) {
return (Survey) sessionFactory.getCurrentSession()
.createQuery("from Survey survey where survey.name = :name")
.setString("name", name).uniqueResult();
}
内容来源于网络,如有侵权,请联系作者删除!