congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Criteria.setLockMode
Code IndexAdd Tabnine to your IDE (free)

How to use
setLockMode
method
in
org.hibernate.Criteria

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

origin: hibernate/hibernate-orm

/**
 * Set the lock mode to use.
 *
 * @param lockMode The lock mode to use
 *
 * @return {@code this}, for method chaining
 */
public DetachedCriteria setLockMode(LockMode lockMode) {
  criteria.setLockMode( lockMode );
  return this;
}
origin: hibernate/hibernate-orm

/**
 * Set an alias-specific lock mode.  The specified lock mode applies only to that alias.
 *
 * @param alias The alias to apply the lock to
 * @param lockMode The lock mode to use.
 *
 * @return {@code this}, for method chaining
 */
public DetachedCriteria setLockMode(String alias, LockMode lockMode) {
  criteria.setLockMode( alias, lockMode );
  return this;
}

origin: kaaproject/kaa

protected T findOneByCriterionWithLock(Criterion criterion, LockMode lockMode) {
 String className = getSimpleClassName();
 LOG.trace("Searching {} entity by criterion [{}] ", className, criterion);
 Criteria criteria = getCriteria();
 criteria.setLockMode(lockMode);
 criteria.add(criterion);
 return (T) criteria.uniqueResult();
}
origin: hibernate/hibernate-orm

@Test
public void testCriteria() {
  Session session = openSession();
  session.beginTransaction();
  Criteria criteria = session.createCriteria( Door.class );
  criteria.setLockMode( LockMode.PESSIMISTIC_WRITE );
  criteria.setFirstResult( 2 );
  criteria.setMaxResults( 2 );
  @SuppressWarnings("unchecked") List<Door> results = criteria.list();
  assertEquals( 2, results.size() );
  for ( Door door : results ) {
    assertEquals( LockMode.PESSIMISTIC_WRITE, session.getCurrentLockMode( door ) );
  }
  session.getTransaction().commit();
  session.close();
}
origin: hibernate/hibernate-orm

@Test
public void testLegacyCriteriaAliasSpecific() {
  // open a session, begin a transaction and lock row
  doInHibernate( this::sessionFactory, session -> {
    A it = (A) session.createCriteria( A.class )
        .setLockMode( "this", LockMode.PESSIMISTIC_WRITE )
        .uniqueResult();
    // make sure we got it
    assertNotNull( it );
    // that initial transaction is still active and so the lock should still be held.
    // Lets open another session/transaction and verify that we cannot update the row
    nowAttemptToUpdateRow();
  } );
}
origin: hibernate/hibernate-orm

@Test
public void testLegacyCriteria() {
  // open a session, begin a transaction and lock row
  doInHibernate( this::sessionFactory, session -> {
    A it = (A) session.createCriteria( A.class )
        .setLockMode( LockMode.PESSIMISTIC_WRITE )
        .uniqueResult();
    // make sure we got it
    assertNotNull( it );
    // that initial transaction is still active and so the lock should still be held.
    // Lets open another session/transaction and verify that we cannot update the row
    nowAttemptToUpdateRow();
  } );
}
origin: org.hibernate/com.springsource.org.hibernate

  public DetachedCriteria setLockMode(String alias, LockMode lockMode) {
    criteria.setLockMode(alias, lockMode);
    return this;
  }
}
origin: TGAC/miso-lims

@Override
public Criteria setLockMode(LockMode lockMode) {
 backingCriteria.setLockMode(lockMode);
 return this;
}
origin: TGAC/miso-lims

@Override
public Criteria setLockMode(String alias, LockMode lockMode) {
 backingCriteria.setLockMode(alias, lockMode);
 return this;
}
origin: theonedev/onedev

  public EntityCriteria<T> setLockMode(String alias, LockMode lockMode) {
    criteria.setLockMode(alias, lockMode);
    return this;
  }
}
origin: org.hibernate/com.springsource.org.hibernate.core

  public DetachedCriteria setLockMode(String alias, LockMode lockMode) {
    criteria.setLockMode(alias, lockMode);
    return this;
  }
}
origin: ezbz/projectx

@Override
public Criteria setLockMode(final LockMode lockMode) {
 return criteria.setLockMode(lockMode);
}
origin: ezbz/projectx

@Override
public Criteria setLockMode(final String alias, final LockMode lockMode) {
 return criteria.setLockMode(alias, lockMode);
}
origin: theonedev/onedev

public EntityCriteria<T> setLockMode(LockMode lockMode) {
  criteria.setLockMode(lockMode);
  return this;
}
origin: org.hibernate/com.springsource.org.hibernate

public DetachedCriteria setLockMode(LockMode lockMode) {
  criteria.setLockMode(lockMode);
  return this;
}
origin: org.hibernate/com.springsource.org.hibernate.core

public DetachedCriteria setLockMode(LockMode lockMode) {
  criteria.setLockMode(lockMode);
  return this;
}
origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Criteria setLockMode(final LockMode lockMode) {
  criteria.setLockMode(LockModeAdapter.adapt(lockMode));
  return this;
}
origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Criteria setLockMode(final String alias, final LockMode lockMode) {
  criteria.setLockMode(alias, LockModeAdapter.adapt(lockMode));
  return this;
}
origin: stackoverflow.com

 // Load from DB

Criteria crit = session.createCriteria( Dummy.class ).add( Restrictions.eq("id", 5) );

crit.setLockMode( LockMode.UPGRADE  ); // issues a SELECT ... for UPDATE... 

Dummy val = crit.uniqueResult();

 etc.etc
origin: org.grails/grails-datastore-gorm-hibernate-core

@Override
public Query lock(boolean lock) {
  criteria.setCacheable(false);
  criteria.setLockMode(LockMode.PESSIMISTIC_WRITE);
  return super.lock(lock);
}
org.hibernateCriteriasetLockMode

Javadoc

Set the lock mode of the aliased entity.

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
  • createCriteria
    Create a new Criteria, "rooted" at the associated entity, using the specified join type.
  • 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
  • setFetchMode,
  • setCacheable,
  • setFetchSize,
  • scroll,
  • setReadOnly,
  • setCacheRegion,
  • setTimeout,
  • setCacheMode,
  • setFlushMode

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
  • setContentView (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • JCheckBox (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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