本文整理了Java中org.hibernate.classic.Session.getNamedQuery()
方法的一些代码示例,展示了Session.getNamedQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getNamedQuery()
方法的具体详情如下:
包路径:org.hibernate.classic.Session
类名称:Session
方法名:getNamedQuery
暂无
代码示例来源:origin: gocd/gocd
public UsageStatisticsReporting load() {
String cacheKey = cacheKeyForUsageStatisticsReporting();
UsageStatisticsReporting reporting = (UsageStatisticsReporting) goCache.get(cacheKey);
if (reporting == null) {
synchronized (cacheKey) {
if (reporting == null) {
reporting = transactionTemplate.execute(status -> (UsageStatisticsReporting) sessionFactory.getCurrentSession().getNamedQuery("load.usagestatistics.reporting.information").uniqueResult());
goCache.put(cacheKey, reporting);
}
}
}
return reporting;
}
代码示例来源:origin: gocd/gocd
public DataSharingSettings load() {
String cacheKey = cacheKeyForDataSharingSettings();
DataSharingSettings settings = (DataSharingSettings) goCache.get(cacheKey);
if (settings == null) {
synchronized (cacheKey) {
if (settings == null) {
settings = transactionTemplate.execute(status -> (DataSharingSettings) sessionFactory.getCurrentSession().getNamedQuery("load.datasharing.settings").uniqueResult());
goCache.put(cacheKey, settings);
}
}
}
return settings;
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<Group> getAll() {
return session().getNamedQuery("findAllGroups").list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<LastReadPost> getLastReadPostsInTopic(Topic topic) {
return (List<LastReadPost>) session().getNamedQuery("getLastReadPostInTopicForAllUsers")
.setParameter("topic", topic)
.list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public Collection<Banner> getAll() {
return session().getNamedQuery("getAll").list();
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public List<Branch> getAllBranches() {
List<Branch> branches = session()
.getNamedQuery("getAllBranches")
.list();
return branches;
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public int getUsersCount() {
return ((Number) sessionFactory
.getCurrentSession().getNamedQuery("getCountOfUsers")
.setCacheable(true)
.uniqueResult())
.intValue();
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public List<Group> getGroupsOfUser(User user) {
Assert.throwIfNull(user, "user");
Query query = session().getNamedQuery("findGroupsOfUser");
query.setParameter(0, "%" + user + "%");
return query.list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public List<Group> getByName(String name) {
Validate.notNull(name, "User Group name can't be null");
Query query = session().getNamedQuery(FIND_EXACTLY_BY_NAME);
// we should use lower case to search ignoring case
query.setString("name", name);
return query.list();
}
代码示例来源:origin: jtalks-org/jcommune
@Override
public int getGroupUserCount(long id) {
Query query = session().getNamedQuery("getCountUsersInGroup");
query.setParameter("id", id);
Number count = (Number) query.uniqueResult();
return count.intValue();
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public int getCountPostsInBranch(Branch branch) {
Number count = (Number) session()
.getNamedQuery("getCountPostsInBranch")
.setParameter("branch", branch)
.uniqueResult();
return count.intValue();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public int countTopics(Branch branch) {
Number count = (Number) session()
.getNamedQuery("getCountTopicsInBranch")
.setParameter(BRANCH, branch)
.uniqueResult();
return count.intValue();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public LastReadPost getLastReadPost(JCUser forWho, Topic topic) {
return (LastReadPost) session().getNamedQuery("getLastReadPostInTopicForUser")
.setParameter("topic", topic)
.setParameter("user", forWho)
.uniqueResult();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public List<JCUser> getByUsernames(Set<String> usernames) {
//noinspection unchecked
return (List<JCUser>) session().getNamedQuery("getByUsernames")
.setParameterList("usernames", usernames)
.list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public List<Group> getGroupsByIds(List<Long> ids) {
return (List<Group>)session().getNamedQuery("getGroupsByIds")
.setParameterList("ids", ids).list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public List<String> getUsernames(String pattern, int count) {
pattern = SqlLikeEscaper.escapeControlCharacters(pattern);
return session().getNamedQuery("getEnabledUsersNames")
.setParameter("pattern", "%" + pattern.toLowerCase() + "%")
.setMaxResults(count)
.list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public Component getComponent() {
return (Component) session().getNamedQuery("getForumComponent").uniqueResult();
}
}
代码示例来源:origin: jtalks-org/jcommune
@Override
public void changeRating(Long postId, int changes) {
session().getNamedQuery("increaseRating")
.setInteger("valueToAdd", changes)
.setParameter("postId", postId)
.executeUpdate();
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public List<Post> getLastPostsFor(List<Long> branchIds, int postCount) {
return (List<Post>) session()
.getNamedQuery("getLastPostsForBranch")
.setParameterList("branchIds", branchIds)
.setMaxResults(postCount).list();
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public void deleteByUser(JCUser user) {
session().getNamedQuery("deleteByUser")
.setEntity("user", user)
.executeUpdate();
}
}
内容来源于网络,如有侵权,请联系作者删除!