Example usage for org.hibernate.stat SessionStatistics getCollectionKeys

List of usage examples for org.hibernate.stat SessionStatistics getCollectionKeys

Introduction

In this page you can find the example usage for org.hibernate.stat SessionStatistics getCollectionKeys.

Prototype

Set getCollectionKeys();

Source Link

Document

Get the set of all CollectionKeys

Usage

From source file:org.jpos.ee.DB.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
public void printStats() {
    if (getLog() != null) {
        LogEvent info = getLog().createInfo();

        if (session != null) {
            info.addMessage("====  STATISTICS ====");
            SessionStatistics statistics = session().getStatistics();
            info.addMessage("====   ENTITIES  ====");
            Set<EntityKey> entityKeys = statistics.getEntityKeys();
            for (EntityKey ek : entityKeys) {
                info.addMessage(String.format("[%s] %s", ek.getIdentifier(), ek.getEntityName()));
            }/*from w ww .  j  a  v a 2s. c  o m*/
            info.addMessage("==== COLLECTIONS ====");
            Set<CollectionKey> collectionKeys = statistics.getCollectionKeys();
            for (CollectionKey ck : collectionKeys) {
                info.addMessage(String.format("[%s] %s", ck.getKey(), ck.getRole()));
            }
            info.addMessage("=====================");
        } else {
            info.addMessage("Session is not open");
        }
        Logger.log(info);
    }
}

From source file:org.jpos.transaction.DebugDB.java

License:Open Source License

@Override
public int prepare(long id, Serializable context) {
    Context ctx = (Context) context;
    DB db = (DB) ctx.get(TxnConstants.DB);

    Session session = db.session();/*from   w  ww .j a v a  2  s  .  c  om*/
    SessionStatistics statistics = session.getStatistics();
    Set<EntityKey> entityKeys = statistics.getEntityKeys();
    ctx.log(String.format("ENTITIES:  (%d)", statistics.getEntityCount()));
    for (EntityKey ek : entityKeys) {
        Object obj = session.get(ek.getEntityName(), ek.getIdentifier());
        LockMode lockMode = session.getCurrentLockMode(obj);
        ctx.log(String.format("[%s] %s %s", ek.getIdentifier(), ek.getEntityName(), lockMode));
    }
    ctx.log("==== COLLECTIONS ====");
    Set<CollectionKey> collectionKeys = statistics.getCollectionKeys();
    for (CollectionKey ck : collectionKeys) {
        ctx.log(String.format("[%s] %s", ck.getKey(), ck.getRole()));
    }

    ctx.log("=====================");
    return PREPARED | READONLY | NO_JOIN;
}