本文整理了Java中org.jpos.ee.DB.session()
方法的一些代码示例,展示了DB.session()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DB.session()
方法的具体详情如下:
包路径:org.jpos.ee.DB
类名称:DB
方法名:session
暂无
代码示例来源:origin: jpos/jPOS-EE
/**
* @return underlying Hibernate Session.
*/
public Session session () {
return db.session();
}
/**
代码示例来源:origin: jpos/jPOS-EE
public Visitor getVisitor ()
throws HibernateException
{
Visitor v = (Visitor) db.session().get(Visitor.class, digest);
if (v != null)
v.touch();
return v;
}
public Visitor getVisitor (boolean create)
代码示例来源:origin: jpos/jPOS-EE
public int getCompositeAccountsCount() {
CriteriaBuilder criteriaBuilder = db.session().getCriteriaBuilder();
CriteriaQuery<Long> query = criteriaBuilder.createQuery(Long.class);
Root<CompositeAccount> root = query.from(CompositeAccount.class);
query.select(criteriaBuilder.count(root));
return db.session().createQuery(query).getSingleResult().intValue();
}
}
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public Thing getLast (String type) {
Criteria crit = db.session().createCriteria (Thing.class)
.add (Restrictions.eq ("type", type))
.addOrder(Order.desc("id"));
List<Thing> l = crit.list();
return l.size() > 0 ? l.get(0) : null;
}
// === String ==============================================================
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Revision> getRevisionsByAuthor (User author)
throws HibernateException
{
Criteria crit = db.session().createCriteria (Revision.class)
.add (Restrictions.eq ("author", author))
.addOrder (Order.desc("id"));
return (List<Revision>) crit.list();
}
代码示例来源:origin: jpos/jPOS-EE
public int getItemCount() {
CriteriaBuilder criteriaBuilder = db.session().getCriteriaBuilder();
CriteriaQuery<Long> query = criteriaBuilder.createQuery(Long.class);
Root<T> root = query.from(clazz);
Predicate[] predicates = buildFilters(root);
if (predicates != null)
query.where(predicates);
query.select(criteriaBuilder.count(root));
return db.session().createQuery(query).getSingleResult().intValue();
}
代码示例来源:origin: jpos/jPOS-EE
public synchronized void commit()
{
if (session() != null)
{
Transaction tx = session().getTransaction();
if (tx != null && tx.getStatus().isOneOf(TransactionStatus.ACTIVE))
{
tx.commit();
}
}
}
代码示例来源:origin: jpos/jPOS-EE
@Override
protected Predicate[] buildFilters(Root<SysConfig> root) {
Predicate[] predicates = new Predicate[] {
db.session().getCriteriaBuilder().like(root.get("id"),prefix + "%")
};
return predicates;
}
代码示例来源:origin: jpos/jPOS-EE
public T getItemByParam(String param, Object value, boolean withFilter) {
try {
CriteriaQuery<T> query = createQueryByParam(param, value, withFilter);
return db.session().createQuery(query).getSingleResult();
} catch (NoResultException nre) {
return null;
}
}
代码示例来源:origin: jpos/jPOS-EE
public List<T> getItemsByParam(String param, Object value, boolean withFilter) {
try {
CriteriaQuery<T> query = createQueryByParam(param, value, withFilter);
return db.session().createQuery(query).list();
} catch (NoResultException nre) {
return null;
}
}
代码示例来源:origin: jpos/jPOS-EE
@Override
public Object getEntityByParam(String param) {
try {
return DB.exec(db -> {
db.session().enableFetchProfile("eager");
return db.session().get(clazz, param);
});
} catch (Exception e) {
getApp().getLog().error(e);
return null;
}
}
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByTextValue (String type, String value) {
Query query = db.session().getNamedQuery ("list-by-text-value")
.setString ("type", type)
.setString ("value", value);
return (List<Thing>) query.list();
}
@SuppressWarnings("unchecked")
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByDateName (String type, String name) {
Query query = db.session().getNamedQuery ("list-by-date-name")
.setString ("type", type)
.setString ("name", name);
return (List<Thing>) query.list();
}
@SuppressWarnings("unchecked")
代码示例来源:origin: jpos/jPOS-EE
private int getChildrenCount(Account parent) throws Exception {
return DB.exec(db -> {
db.session().refresh(parent);
return parent.getChildren().size();
});
}
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByTextName (String type, String name) {
Query query = db.session().getNamedQuery ("list-by-text-name")
.setString ("type", type)
.setString ("name", name);
return (List<Thing>) query.list();
}
@SuppressWarnings("unchecked")
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByLongValue (String type, long value) {
Query query = db.session().getNamedQuery ("list-by-long-value")
.setString ("type", type)
.setLong ("value", value);
return (List<Thing>) query.list();
}
@SuppressWarnings("unchecked")
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByBigDecimalValue (String type, BigDecimal value) {
Query query = db.session().getNamedQuery ("list-by-big-decimal-value")
.setString ("type", type)
.setBigDecimal ("value", value);
return (List<Thing>) query.list();
}
@SuppressWarnings("unchecked")
代码示例来源:origin: jpos/jPOS-EE
public Journal getJournal (long id) {
try {
return (Journal) DB.exec(db -> db.session().get(Journal.class, id));
} catch (Exception e) {
getApp().getLog().error(e);
return null;
}
}
}
代码示例来源:origin: jpos/jPOS-EE
@SuppressWarnings("unchecked")
public List<Thing> listByTimestampNameValue (String type, String name, Date value) {
Query query = db.session().getNamedQuery ("list-by-timestamp-name-value")
.setString ("type", type)
.setString ("name", name)
.setTimestamp ("value", value);
return (List<Thing>) query.list();
}
代码示例来源:origin: jpos/jPOS-EE
private void create (String id) {
try (DB db = new DB()) {
db.open();
db.beginTransaction();
SeqNo seq = new SeqNo(id);
db.session().save(seq);
db.commit();
} catch (Exception ignored) { }
}
}
内容来源于网络,如有侵权,请联系作者删除!