Package org.hibernate

Examples of org.hibernate.Session.createQuery()


      //pretend you care
      return new LetThroughExecuteUpdateQuery();
    }

    Session session = (Session) getDelegate();
    return applyProperties( new OgmJpaQuery<Object>( session.createQuery( qlString ), hibernateEm ) );
  }

  private Query applyProperties(Query query) {
    if ( lockOptions.getLockMode() != LockMode.NONE ) {
      query.setLockMode( getLockMode( lockOptions.getLockMode() ) );
View Full Code Here


  @Override
  public <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass) {
    // do the translation
    Session session = (Session) getDelegate();
    org.hibernate.Query query = session.createQuery( qlString );

    resultClassChecking( resultClass, query );

    // finally, build/return the query instance
    return new OgmJpaQuery<T>( query, hibernateEm );
View Full Code Here

  public void challenge(Message message) {
    @SuppressWarnings({"unchecked"}) Session session = ((ResourceProvider<Session>) message.getResource(ResourceProvider.class, "SessionProvider")).get();
    final String name = message.get(String.class, SecurityParts.Name);
    final String password = message.get(String.class, SecurityParts.Password);

    Object userObj = session.createQuery(challengeQueryString)
        .setString("name", name)
        .setString("password", password)
        .uniqueResult();

    if (userObj != null) {
View Full Code Here

      return;
    }

    Session tmpSession = sessionFactory.openSession();
    try {
      List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();

      Map<String,Integer> items = new HashMap<String,Integer>();
      if ( !list.isEmpty() ) {
        for ( Object element : list ) {
          Integer l = items.get( tmpSession.getEntityName( element ) );
View Full Code Here

    return query.executeUpdate();
  }
 
  public int batchUpdateByQuery(String queryString, Map<String, Object> params) {
    Session session = getSession();
    Query query = session.createQuery(queryString);
    logger.debug("Batch Update[{}]", queryString);
    if(params != null && !params.keySet().isEmpty()){
      logger.debug("Parameter List:");
      int i=1;
      for(String key: params.keySet()){
View Full Code Here

    Session session = getSession();
    if(sorts != null && sorts.length > 0){
      query += " order by " + StringUtil.join(sorts);
    }
    logger.debug("Find[{}]", query);
    return findByQueryNative(session.createQuery(query), params, start, pageSize);
  }
 
  protected <T> Pagination<T> findByNamedQueryNative(String queryName, Map<String,Object> params,
      Sort[] sorts, int start, int pageSize, boolean withGroupby){
    Session session = getSession();
View Full Code Here

      Pagination<T> p = new Pagination<T>();
      List<T> list = findByQueryNative(query, params,  start, pageSize);
      p.setItems(list)
      String countQueryString = getCountQueryStringForHql(queryString);
      if(withGroupby)
        p.setCount((long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).size());
      else
        p.setCount((Long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).iterator().next());
      return setPagination(p, start, pageSize, sorts);
    }else{
      return findByQueryNative(queryString, params, sorts, start, pageSize, withGroupby);
View Full Code Here

      p.setItems(list)
      String countQueryString = getCountQueryStringForHql(queryString);
      if(withGroupby)
        p.setCount((long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).size());
      else
        p.setCount((Long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).iterator().next());
      return setPagination(p, start, pageSize, sorts);
    }else{
      return findByQueryNative(queryString, params, sorts, start, pageSize, withGroupby);
    }   
  }
View Full Code Here

    Pagination<T> p = new Pagination<T>();
    List<T> list = findByQueryNative(query, params, sorts, start, pageSize);
    p.setItems(list);
    String countQueryString = getCountQueryStringForHql(query);
    if(withGroupby)
      p.setCount((long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).size());
    else
      p.setCount((Long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).iterator().next());
    return setPagination(p, start, pageSize, sorts);
 
 
View Full Code Here

    p.setItems(list);
    String countQueryString = getCountQueryStringForHql(query);
    if(withGroupby)
      p.setCount((long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).size());
    else
      p.setCount((Long)findByQueryNative(session.createQuery(countQueryString), params, -1, -1).iterator().next());
    return setPagination(p, start, pageSize, sorts);
 
 
  @SuppressWarnings("unchecked")
  private <T> List<T> findByQueryExNative(String queryString, Map<String, Object> params,
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.