Tabnine Logo
Criteria.createCriteria
Code IndexAdd Tabnine 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)

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", 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.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

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • onRequestPermissionsResult (Fragment)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now