EntityPersister isVersioned - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for EntityPersister isVersioned method.

This code example shows how to use the following methods:getInstrumentationMetadata, getVersionProperty, isVersioned, setPropertyValue
		loadedState[ persister.getVersionProperty() ] = version;
		//noinspection deprecation 
		setLockMode( LockMode.FORCE );  // TODO:  use LockMode.PESSIMISTIC_FORCE_INCREMENT
		persister.setPropertyValue( entity, getPersister().getVersionProperty(), nextVersion );
	} 
 
	public boolean isReadOnly() { 
		if (status != Status.MANAGED && status != Status.READ_ONLY) {
			throw new HibernateException("instance was not in a valid state");
		} 
		return status == Status.READ_ONLY;
	} 
 
	public void setReadOnly(boolean readOnly, Object entity) {
		if ( readOnly == isReadOnly() ) {
			// simply return since the status is not being changed 
			return; 
		} 
		if ( readOnly ) {
			setStatus( Status.READ_ONLY );

6
CodeRank
This code example shows how to use the following methods:getVersionProperty, isVersioned
	 * 
	 * @param version The current version 
	 * @param versionType The version type 
	 * @param session The originating session 
	 * @return The incremented optimistic locking value. 
	 */ 
	public static Object increment(Object version, VersionType versionType, SessionImplementor session) { 
		Object next = versionType.next( version, session ); 
        if (LOG.isTraceEnabled()) LOG.trace("Incrementing: " + versionType.toLoggableString(version, session.getFactory()) + " to " 
                                            + versionType.toLoggableString(next, session.getFactory())); 
		return next; 
	} 
 
	/** 
	 * Inject the optimisitc locking value into the entity state snapshot. 
	 * 
	 * @param fields The state snapshot 
	 * @param version The optimisitc locking value 
	 * @param persister The entity persister 
	 */ 
5
CodeRank
This code example shows how to use the following methods:getIdentifierGenerator, getPropertyValues, getVersionProperty, getVersionType, isVersioned
		} 
		if ( id == IdentifierGeneratorHelper.POST_INSERT_INDICATOR ) { 
			id = persister.insert(state, entity, this); 
		} 
		else { 
			persister.insert(id, state, entity, this); 
		} 
		persister.setIdentifier( entity, id, this ); 
		return id; 
	} 
 
 
	// deletes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 
	public void delete(Object entity) { 
		errorIfClosed(); 
		delete(null, entity); 
	} 
 
	public void delete(String entityName, Object entity) { 

5
CodeRank
This code example shows how to use the following methods:getEntityName, isVersioned
		} 
	} 
 
	/** 
	 * @see LockingStrategy#lock 
	 */ 
	public void lock( 
			Serializable id,
			Object version, 
			Object object, 
			int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException {
		if ( !lockable.isVersioned() ) {
			throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
		} 
		EntityEntry entry = session.getPersistenceContext().getEntry( object );
		EntityIncrementVersionProcess incrementVersion = new EntityIncrementVersionProcess( object, entry );
		EventSource source = (EventSource) session;
		// Register the EntityIncrementVersionProcess action to run just prior to transaction commit.  
		source.getActionQueue().registerProcess( incrementVersion );
	} 
7
CodeRank
This code example shows how to use the following methods:getEntityName, isVersioned
			throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" );
		} 
	} 
 
   /** 
	 * @see org.hibernate.dialect.lock.LockingStrategy#lock 
	 */ 
	public void lock( 
      Serializable id,
      Object version, 
      Object object, 
      int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException {
		if ( !lockable.isVersioned() ) {
			throw new OptimisticLockException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
		} 
		EntityEntry entry = session.getPersistenceContext().getEntry(object);
		EventSource source = (EventSource)session;
		EntityVerifyVersionProcess verifyVersion = new EntityVerifyVersionProcess(object, entry);
		// Register the EntityVerifyVersionProcess action to run just prior to transaction commit. 
		source.getActionQueue().registerProcess(verifyVersion);
7
CodeRank
This code example shows how to use the following methods:getEntityName, getFactory, isVersioned, getRootTableIdentifierColumnNames, getRootTableName
		registerColumnType( Types.CHAR, "char(1)" );
		registerColumnType( Types.VARCHAR, "varchar($l)" );
		registerColumnType( Types.FLOAT, "float" );
		registerColumnType( Types.DOUBLE, "double precision" );
		registerColumnType( Types.DATE, "date" );
		registerColumnType( Types.TIME, "time" );
		registerColumnType( Types.TIMESTAMP, "timestamp" );
		//the BLOB type requires a size arguement - this defaults to 
		//bytes - no arg defaults to 1 whole byte! 
		//other argument mods include K - kilobyte, M - megabyte, G - gigabyte. 
		//refer to the PBdevelopers guide for more info. 
		registerColumnType( Types.VARBINARY, "blob($l)" );
		registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
	} 
 
	public String getAddColumnString() {
		return "add"; 
	} 
 
	public boolean dropConstraints() { 

8
CodeRank
This code example shows how to use the following methods:getEntityName, isVersioned
		} 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public void lock( 
			Serializable id,
			Object version, 
			Object object, 
			int timeout,
			SessionImplementor session) throws StaleObjectStateException, JDBCException {
		if ( !lockable.isVersioned() ) {
			throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
		} 
		EntityEntry entry = session.getPersistenceContext().getEntry( object );
		final EntityPersister persister = entry.getPersister();
		Object nextVersion = persister.forceVersionIncrement( entry.getId(), entry.getVersion(), session );
		entry.forceLocked( object, nextVersion );
	} 
7
CodeRank
This code example shows how to use the following methods:getEntityName, getFactory, isVersioned, getRootTableIdentifierColumnNames, getRootTableName
public class FrontBaseDialect extends Dialect {
 
	public FrontBaseDialect() { 
		super(); 
 
		registerColumnType( Types.BIT, "bit" );
		registerColumnType( Types.BIGINT, "longint" );
		registerColumnType( Types.SMALLINT, "smallint" );
		registerColumnType( Types.TINYINT, "tinyint" );
		registerColumnType( Types.INTEGER, "integer" );
		registerColumnType( Types.CHAR, "char(1)" );
		registerColumnType( Types.VARCHAR, "varchar($l)" );
		registerColumnType( Types.FLOAT, "float" );
		registerColumnType( Types.DOUBLE, "double precision" );
		registerColumnType( Types.DATE, "date" );
		registerColumnType( Types.TIME, "time" );
		registerColumnType( Types.TIMESTAMP, "timestamp" );
		registerColumnType( Types.VARBINARY, "bit varying($l)" );
		registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
		registerColumnType( Types.BLOB, "blob" );

8
CodeRank
This code example shows how to use the following methods:getEntityName, getFactory, isVersioned, getRootTableIdentifierColumnNames, getRootTableName
		registerColumnType( Types.SMALLINT, "smallint" );
		registerColumnType( Types.TINYINT, "tinyint" );
		registerColumnType( Types.INTEGER, "integer" );
		registerColumnType( Types.CHAR, "char(1)" );
		registerColumnType( Types.VARCHAR, "varchar($l)" );
		registerColumnType( Types.FLOAT, "float" );
		registerColumnType( Types.DOUBLE, "double" );
		registerColumnType( Types.DATE, "date" );
		registerColumnType( Types.TIME, "time" );
		registerColumnType( Types.TIMESTAMP, "timestamp" );
		registerColumnType( Types.VARBINARY, "varbinary" );
		registerColumnType( Types.NUMERIC, "numeric" );
		registerColumnType( Types.BLOB, "blob" );
		registerColumnType( Types.CLOB, "clob" );
 
		registerFunction( "upper", new StandardSQLFunction("upper") );
		registerFunction( "lower", new StandardSQLFunction("lower") );
		registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) );
		registerFunction( "abs", new StandardSQLFunction("abs") );
		registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );

8
CodeRank
This code example shows how to use the following methods:getEntityName, getFactory, isVersioned, getRootTableIdentifierColumnNames, getRootTableName
 * No CLOB/BLOB support  
 * No cascade delete support. 
 * No Calendar support 
 * No support for updating primary keys. 
 *  
 * @author Sherry Listgarten and Max Andersen 
 */ 
public class TimesTenDialect extends Dialect {
	 
	public TimesTenDialect() { 
		super(); 
		registerColumnType( Types.BIT, "TINYINT" );
		registerColumnType( Types.BIGINT, "BIGINT" );
		registerColumnType( Types.SMALLINT, "SMALLINT" );
		registerColumnType( Types.TINYINT, "TINYINT" );
		registerColumnType( Types.INTEGER, "INTEGER" );
		registerColumnType( Types.CHAR, "CHAR(1)" );
		registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
		registerColumnType( Types.FLOAT, "FLOAT" );
		registerColumnType( Types.DOUBLE, "DOUBLE" );

8
CodeRank
isVersioned Method Overview
Determine whether optimistic locking by column is enabled for this entity.
See Code Examples for other Hibernate ORM EntityPersister Methods: