本文整理了Java中org.hibernate.classic.Session.createCriteria()
方法的一些代码示例,展示了Session.createCriteria()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.createCriteria()
方法的具体详情如下:
包路径:org.hibernate.classic.Session
类名称:Session
方法名:createCriteria
暂无
代码示例来源:origin: gocd/gocd
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
return sessionFactory.getCurrentSession()
.createCriteria(PipelineState.class)
.add(Restrictions.eq("pipelineName", pipelineName))
.setCacheable(false).uniqueResult();
}
});
代码示例来源:origin: gocd/gocd
@Override
public Object doInTransaction(TransactionStatus status) {
PropertyProjection pipelineName = Projections.property("pipelineName");
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PipelineState.class).setProjection(pipelineName).add(
Restrictions.eq("locked", true));
criteria.setCacheable(false);
List<String> list = criteria.list();
return list;
}
});
代码示例来源:origin: gocd/gocd
@Override
public JobAgentMetadata load(final Long jobId) {
return (JobAgentMetadata) transactionTemplate.execute((TransactionCallback) transactionStatus -> sessionFactory.getCurrentSession()
.createCriteria(JobAgentMetadata.class)
.add(Restrictions.eq("jobId", jobId))
.setCacheable(true).uniqueResult());
}
代码示例来源:origin: gocd/gocd
@Override
public VersionInfo findByComponentName(final String name) {
return (VersionInfo) transactionTemplate.execute((TransactionCallback) transactionStatus -> sessionFactory.getCurrentSession()
.createCriteria(VersionInfo.class)
.add(Restrictions.eq("componentName", name))
.setCacheable(true).uniqueResult());
}
代码示例来源:origin: gocd/gocd
public Users findNotificationSubscribingUsers() {
return (Users) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(User.class);
criteria.setCacheable(true);
criteria.add(Restrictions.isNotEmpty("notificationFilters"));
criteria.add(Restrictions.eq("enabled", true));
return new Users(criteria.list());
});
}
代码示例来源:origin: gocd/gocd
public User findUser(final String userName) {
return (User) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
User user = (User) sessionFactory.getCurrentSession()
.createCriteria(User.class)
.add(Restrictions.eq("name", userName))
.setCacheable(true).uniqueResult();
return user == null ? new NullUser() : user;
});
}
代码示例来源:origin: gocd/gocd
public EnvironmentVariables load(final Long entityId, final EnvironmentVariableType type) {
List<EnvironmentVariable> result = (List<EnvironmentVariable>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(EnvironmentVariable.class).add(Restrictions.eq("entityId", entityId)).add(
Restrictions.eq("entityType", type.toString())).addOrder(Order.asc("id"));
criteria.setCacheable(true);
return criteria.list();
});
return new EnvironmentVariables(result);
}
代码示例来源:origin: gocd/gocd
@Override
public Plugin findPlugin(final String pluginId) {
String cacheKey = cacheKeyForPluginSettings(pluginId);
Plugin plugin = (Plugin) goCache.get(cacheKey);
if (plugin != null) {
return plugin;
}
synchronized (cacheKey) {
plugin = (Plugin) goCache.get(cacheKey);
if (plugin != null) {
return plugin;
}
plugin = (Plugin) transactionTemplate.execute((TransactionCallback) transactionStatus -> sessionFactory.getCurrentSession()
.createCriteria(Plugin.class)
.add(Restrictions.eq("pluginId", pluginId))
.setCacheable(true).uniqueResult());
if (plugin != null) {
goCache.put(cacheKey, plugin);
return plugin;
}
goCache.remove(cacheKey);
return new NullPlugin();
}
}
代码示例来源:origin: denimgroup/threadfix
public Criteria getActiveRPACriteria() {
return sessionFactory.getCurrentSession()
.createCriteria(RemoteProviderApplication.class)
.add(Restrictions.eq("active",true));
}
}
代码示例来源:origin: denimgroup/threadfix
public Criteria getActiveVulnCriteria() {
return sessionFactory.getCurrentSession()
.createCriteria(Vulnerability.class)
.add(Restrictions.eq("active", true))
.add(Restrictions.eq("hidden", false))
.add(Restrictions.eq("isFalsePositive", false));
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<Report> retrieveAllNativeReports() {
return (List<Report>) sessionFactory.getCurrentSession()
.createCriteria(getClassReference())
.add(Restrictions.eq("nativeReport", true))
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
@SuppressWarnings("unchecked")
public List<Report> retrieveAllNonNativeReports() {
return (List<Report>) sessionFactory.getCurrentSession()
.createCriteria(getClassReference())
.add(Restrictions.eq("nativeReport", false))
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public AccessControlApplicationMap retrieveAppMapById(int id) {
return (AccessControlApplicationMap) sessionFactory.getCurrentSession()
.createCriteria(AccessControlApplicationMap.class)
.add(Restrictions.eq("id",id))
.add(Restrictions.eq("active",true))
.uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public List<VulnerabilityComment> retrieveAllActive() {
return sessionFactory.getCurrentSession()
.createCriteria(VulnerabilityComment.class)
.add(Restrictions.eq("active", true))
.addOrder(Order.asc("id"))
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public List<Finding> retrieveByGenericSeverityAndChannelType(GenericSeverity genericSeverity, ChannelType channelType) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Finding.class, "finding")
.createCriteria("finding.channelVulnerability", "channelVulnerability")
.createCriteria("finding.channelSeverity", "channelSeverity")
.createCriteria("channelSeverity.severityMap", "severityMap")
.add(Restrictions.eq("severityMap.genericSeverity", genericSeverity))
.add(Restrictions.eq("channelVulnerability.channelType", channelType));
return criteria.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public List<Finding> getFindingsWithIds(List<Integer> findingIds) {
if (findingIds == null || findingIds.isEmpty()) {
return list();
}
return sessionFactory.getCurrentSession()
.createCriteria(Finding.class)
.add(isEmpty("statisticsCounters"))
.add(in("id", findingIds))
.list();
}
代码示例来源:origin: denimgroup/threadfix
@SuppressWarnings("unchecked")
@Override
public List<AccessControlTeamMap> retrieveAllMapsForGroup(Integer id) {
return sessionFactory.getCurrentSession()
.createCriteria(AccessControlTeamMap.class)
.createAlias("organization", "orgAlias")
.createAlias("group", "groupAlias")
.add(Restrictions.eq("groupAlias.id",id))
.add(Restrictions.eq("active",true))
.addOrder(Order.asc("orgAlias.name"))
.list();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public long getNumberWithoutChannelVulns(Integer scanId) {
return (Long) sessionFactory.getCurrentSession()
.createCriteria(Finding.class)
.add(isNull("channelVulnerability"))
.add(eq("scan.id", scanId))
.setProjection(rowCount())
.uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public Long countLogs() {
return (Long) sessionFactory
.getCurrentSession()
.createCriteria(ExceptionLog.class)
.setProjection(Projections.rowCount())
.uniqueResult();
}
代码示例来源:origin: denimgroup/threadfix
@Override
public Calendar getMostRecentScanTime(Integer channelId) {
return (Calendar) sessionFactory
.getCurrentSession()
.createCriteria(Scan.class)
.addOrder(Order.desc("importTime"))
.setProjection(Projections.property("importTime"))
.setMaxResults(1)
.uniqueResult();
}
}
内容来源于网络,如有侵权,请联系作者删除!