Package org.hibernate

Examples of org.hibernate.Session.byId()


    final World[] worlds = new World[queries];
    final Random random = ThreadLocalRandom.current();
    final Session session = sessionFactory.openSession();
   
    for (int i = 0; i < queries; i++) {
        worlds[i] = (World) session.byId(World.class).load(random.nextInt(DB_ROWS) + 1);
    }
   
    session.close();
    return queries == 1 ? worlds[0] : worlds;
  }
View Full Code Here


                final World[] worlds = new World[queries];
                final Session session = HibernateUtil.getSession();
                final Random random = ThreadLocalRandom.current();
               
                for (int i = 0; i < queries; i++) {
                    worlds[i] = (World) session.byId(World.class).load(random.nextInt(DB_ROWS) + 1);
                }
               
                return (request.queryParams("queries") == null ? worlds[0] : worlds);
            }
           
View Full Code Here

        Session session = sessionManager.getSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            SqlWorkspace sqlWorkspace = (SqlWorkspace) session.byId(SqlWorkspace.class).load(workspace.getWorkspaceId());
            List<SqlWorkspaceUser> sqlWorkspaceUsers = sqlWorkspace.getSqlWorkspaceUserList();
            boolean updateUser = false;
            for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) {
                if (sqlWorkspaceUser.getUser().getUserId().equals(userId)) {
                    updateUser = true;
View Full Code Here

     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public T get(PK id) {
        Session sess = getSession();
        IdentifierLoadAccess byId = sess.byId(persistentClass);
        T entity = (T) byId.load(id);

        if (entity == null) {
            log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found...");
            throw new ObjectRetrievalFailureException(this.persistentClass, id);
View Full Code Here

     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public boolean exists(PK id) {
        Session sess = getSession();
        IdentifierLoadAccess byId = sess.byId(persistentClass);
        T entity = (T) byId.load(id);
        return entity != null;
    }

    /**
 
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void remove(PK id) {
        Session sess = getSession();
        IdentifierLoadAccess byId = sess.byId(persistentClass);
        T entity = (T) byId.load(id);
        sess.delete(entity);
    }

    /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.