Codota Logo
Criteria.createCriteria
Code IndexAdd Codota to your IDE (free)

How to use
createCriteria
method
in
org.hibernate.Criteria

Best Java code snippets using org.hibernate.Criteria.createCriteria (Showing top 20 results out of 459)

  • Common ways to obtain Criteria
private void myMethod () {
Criteria c =
  • Codota IconSession session;Class persistentClass;session.createCriteria(persistentClass)
  • Smart code suggestions by Codota
}
origin: hibernate/hibernate-orm

/**
 * Creates a nested DetachedCriteria representing the association path.
 *
 * @param associationPath The association path
 *
 * @return the newly created, nested DetachedCriteria
 */
public DetachedCriteria createCriteria(String associationPath) {
  return new DetachedCriteria( impl, criteria.createCriteria( associationPath ) );
}
origin: hibernate/hibernate-orm

/**
 * Creates a nested DetachedCriteria representing the association path, specifying the type of join to use.
 *
 * @param associationPath The association path
 * @param alias The alias to associate with this "join".
 * @param joinType The type of join to use
 *
 * @return the newly created, nested DetachedCriteria
 */
public DetachedCriteria createCriteria(String associationPath, String alias, JoinType joinType) {
  return new DetachedCriteria( impl, criteria.createCriteria( associationPath, alias, joinType ) );
}
origin: hibernate/hibernate-orm

/**
 * Creates a nested DetachedCriteria representing the association path.
 *
 * @param associationPath The association path
 * @param alias The alias to apply to that association path
 *
 * @return the newly created, nested DetachedCriteria
 */
public DetachedCriteria createCriteria(String associationPath, String alias) {
  return new DetachedCriteria( impl, criteria.createCriteria( associationPath, alias ) );
}
origin: hibernate/hibernate-orm

/**
 * Creates a nested DetachedCriteria representing the association path, specifying the type of join to use.
 *
 * @param associationPath The association path
 * @param joinType The type of join to use
 *
 * @return the newly created, nested DetachedCriteria
 */
public DetachedCriteria createCriteria(String associationPath, JoinType joinType) {
  return new DetachedCriteria( impl, criteria.createCriteria( associationPath, joinType ) );
}
origin: hibernate/hibernate-orm

/**
 * Creates a nested DetachedCriteria representing the association path, specifying the type of join to use and
 * an additional join restriction.
 *
 * @param associationPath The association path
 * @param alias The alias to associate with this "join".
 * @param joinType The type of join to use
 * @param withClause The additional join restriction
 *
 * @return the newly created, nested DetachedCriteria
 */
public DetachedCriteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause)  {
  return new DetachedCriteria(impl, criteria.createCriteria( associationPath, alias, joinType, withClause ) );
}
origin: hibernate/hibernate-orm

@Test
public void testCriteriaRestrictionOnKeyManyToOne() {
  Session s = openSession();
  s.beginTransaction();
  s.createQuery( "from Order o where o.customer.name = 'Acme'" ).list();
  Criteria criteria = s.createCriteria( Order.class );
  criteria.createCriteria( "customer" ).add( Restrictions.eq( "name", "Acme" ) );
  criteria.list();
  s.getTransaction().commit();
  s.close();
}
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.enrolments", "e", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.addresses", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.preferredCourse", "p", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.preferredCourse", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.enrolments", Criteria.LEFT_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

@Test
public void testDiscriminatorFiltering() throws Exception {
  if ( ( getDialect() instanceof HSQLDialect ) ) return;
  Session s = openSession();
  Transaction t = s.beginTransaction();
  s.createQuery("from C1 c1 left join c1.c2s c2").list();
  s.createCriteria(C1.class).createCriteria("c2s").list();
  t.commit();
  s.close();
}
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-7767" )
public void testCriteriaRestrictionOnIdManyToOne() {
  Session s = openSession();
  s.beginTransaction();
  s.createQuery( "from Course c join c.students cs join cs.student s where s.name = 'Foo'" ).list();
  Criteria criteria = s.createCriteria( Course.class );
  criteria.createCriteria( "students" ).createCriteria( "student" ).add( Restrictions.eq( "name", "Foo" ) );
  criteria.list();
  Criteria criteria2 = s.createCriteria( Course.class );
  criteria2.createAlias( "students", "cs" );
  criteria2.add( Restrictions.eq( "cs.value", "Bar" ) );
  criteria2.createAlias( "cs.student", "s" );
  criteria2.add( Restrictions.eq( "s.name", "Foo" ) );
  criteria2.list();
  s.getTransaction().commit();
  s.close();
}
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.preferredCourse", "pCourse", Criteria.LEFT_JOIN )
        .setFetchMode( "preferredCourse", FetchMode.JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
        .setFetchMode( "a", FetchMode.JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.preferredCourse", "pCourse", Criteria.LEFT_JOIN )
        .setFetchMode( "pCourse", FetchMode.JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

  protected Criteria getCriteria(Session s) {
    // should use RootEntityTransformer by default
    return s.createCriteria( Student.class, "s" )
        .createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
        .setFetchMode( "addresses", FetchMode.JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
origin: hibernate/hibernate-orm

private EntityMapEnum assertFindCriteria(
    EntityMapEnum expected,
    String mapPath, Object param) {
  assertNotEquals( 0, expected.id );
  Session session = openNewSession();
  session.beginTransaction();
  EntityMapEnum found = (EntityMapEnum) session.createCriteria( EntityMapEnum.class )
      .createCriteria( mapPath, "m" )
      .add( Restrictions.eq( "indices", param ) )
      .uniqueResult();
  //find
  assetEntityMapEnumEquals( expected, found );
  session.getTransaction().commit();
  session.close();
  return found;
}
origin: hibernate/hibernate-orm

  @Override
  protected Criteria getCriteria(Session s) {
    return s.createCriteria( Student.class, "s" )
        .createAlias( "s.addresses", "a", CriteriaSpecification.LEFT_JOIN )
            .setResultTransformer( CriteriaSpecification.ALIAS_TO_ENTITY_MAP )
        .createCriteria( "s.preferredCourse", CriteriaSpecification.INNER_JOIN )
        .addOrder( Order.asc( "s.studentNumber") );
  }
};
org.hibernateCriteriacreateCriteria

Javadoc

Create a new Criteria, "rooted" at the associated entity.

Functionally equivalent to #createCriteria(String,org.hibernate.sql.JoinType) using JoinType#INNER_JOIN for the joinType.

Popular methods of Criteria

  • list
    Get the results.
  • add
    Add a Criterion to constrain the results to be retrieved.
  • uniqueResult
    Convenience method to return a single instance that matches the query, or null if the query returns
  • addOrder
    Add an Order to the result set.
  • setProjection
    Used to specify that the query results will be a projection (scalar in nature). Implicitly specifies
  • setMaxResults
    Set a limit upon the number of objects to be retrieved.
  • setFirstResult
    Set the first result to be retrieved.
  • setResultTransformer
    Set a strategy for handling the query results. This determines the "shape" of the query result.
  • createAlias
    Join an association using the specified join-type, assigning an alias to the joined association. The
  • setFetchMode
    Specify an association fetching strategy for an association or a collection of values.
  • setCacheable
    Enable caching of this query result, provided query caching is enabled for the underlying session fa
  • setFetchSize
    Set a fetch size for the underlying JDBC query.
  • setCacheable,
  • setFetchSize,
  • scroll,
  • setLockMode,
  • setReadOnly,
  • setCacheRegion,
  • setTimeout,
  • setCacheMode,
  • setFlushMode

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Reference (javax.naming)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now