Search in sources :

Example 16 with KapuaEid

use of org.eclipse.kapua.commons.model.id.KapuaEid in project kapua by eclipse.

the class IdGeneratorServiceImpl method generate.

@Override
public KapuaId generate() throws KapuaException {
    KapuaEid id = null;
    EntityManager em = null;
    try {
        em = CommonsEntityManagerFactory.getEntityManager();
        Query q = em.createNativeQuery(QUERY_SELECT_UUID_SHORT);
        BigInteger bi = (BigInteger) q.getSingleResult();
        id = new KapuaEid(bi);
    } catch (Exception pe) {
        throw new KapuaRuntimeException(KapuaCommonsErrorCodes.ID_GENERATION_ERROR, pe);
    } finally {
        if (em != null) {
            em.close();
        }
    }
    return id;
}
Also used : EntityManager(org.eclipse.kapua.commons.jpa.EntityManager) Query(javax.persistence.Query) KapuaRuntimeException(org.eclipse.kapua.KapuaRuntimeException) BigInteger(java.math.BigInteger) KapuaEid(org.eclipse.kapua.commons.model.id.KapuaEid) KapuaRuntimeException(org.eclipse.kapua.KapuaRuntimeException) KapuaException(org.eclipse.kapua.KapuaException)

Aggregations

KapuaEid (org.eclipse.kapua.commons.model.id.KapuaEid)16 Test (org.junit.Test)10 KapuaId (org.eclipse.kapua.model.id.KapuaId)7 Date (java.util.Date)6 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)6 AccountCreator (org.eclipse.kapua.service.account.AccountCreator)5 AccountService (org.eclipse.kapua.service.account.AccountService)5 Account (org.eclipse.kapua.service.account.Account)4 BigInteger (java.math.BigInteger)3 DeviceCreator (org.eclipse.kapua.service.device.registry.DeviceCreator)3 Session (org.apache.shiro.session.Session)2 Subject (org.apache.shiro.subject.Subject)2 KapuaException (org.eclipse.kapua.KapuaException)2 KapuaSession (org.eclipse.kapua.commons.security.KapuaSession)2 AccessToken (org.eclipse.kapua.service.authentication.AccessToken)2 AccessTokenImpl (org.eclipse.kapua.service.authentication.AccessTokenImpl)2 HashMap (java.util.HashMap)1 StringTokenizer (java.util.StringTokenizer)1 PrePersist (javax.persistence.PrePersist)1 Query (javax.persistence.Query)1