Example usage for org.hibernate.engine.spi CollectionKey getRole

List of usage examples for org.hibernate.engine.spi CollectionKey getRole

Introduction

In this page you can find the example usage for org.hibernate.engine.spi CollectionKey getRole.

Prototype

public String getRole() 

Source Link

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  ww w.ja v a2 s . 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  w w.  j a  v a  2 s  . com*/
    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;
}