Example usage for org.hibernate Session bySimpleNaturalId

List of usage examples for org.hibernate Session bySimpleNaturalId

Introduction

In this page you can find the example usage for org.hibernate Session bySimpleNaturalId.

Prototype

<T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass);

Source Link

Document

Create a SimpleNaturalIdLoadAccess instance to retrieve the specified entity by its simple (single attribute) natural id.

Usage

From source file:org.apache.ignite.cache.hibernate.GridHibernateL2CacheSelfTest.java

License:Apache License

/**
 * @param sesFactory Session factory./*from w w  w.j  a va2s.  c o m*/
 * @param cnt Number of entities to load.
 */
private void loadEntities(SessionFactory sesFactory, int cnt) {
    Session ses = sesFactory.openSession();

    try {
        for (int i = 0; i < cnt; i++) {
            Entity e = (Entity) ses.load(Entity.class, i);

            assertEquals("name-" + i, e.getName());

            assertFalse(e.getChildren().isEmpty());

            ses.bySimpleNaturalId(Entity.class).load(e.getName());
        }
    } finally {
        ses.close();
    }
}

From source file:org.jboss.pressgang.ccms.wrapper.DBServerSettingsWrapper.java

License:Open Source License

@Override
public LocaleWrapper getDefaultLocale() {
    if (cachedDefaultLocale == null) {
        final Session session = getEntityManager().unwrap(Session.class);
        cachedDefaultLocale = (Locale) session.bySimpleNaturalId(Locale.class)
                .load(getEntity().getDefaultLocale());
    }/*from w  ww.  j a  v  a 2s .  c om*/
    return getWrapperFactory().create(cachedDefaultLocale, false, LocaleWrapper.class);
}