Java Code Examples for org.hibernate.LockMode#valueOf()

The following examples show how to use org.hibernate.LockMode#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MutableEntityEntry.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Custom deserialization routine used during deserialization of a
 * Session/PersistenceContext for increased performance.
 *
 * @param ois The stream from which to read the entry.
 * @param persistenceContext The context being deserialized.
 *
 * @return The deserialized EntityEntry
 *
 * @throws java.io.IOException If a stream error occurs
 * @throws ClassNotFoundException If any of the classes declared in the stream
 * cannot be found
 */
public static EntityEntry deserialize(
		ObjectInputStream ois,
		PersistenceContext persistenceContext) throws IOException, ClassNotFoundException {
	String previousStatusString;
	return new MutableEntityEntry(
			persistenceContext.getSession().getFactory(),
			(String) ois.readObject(),
			(Serializable) ois.readObject(),
			Status.valueOf( (String) ois.readObject() ),
			( previousStatusString = (String) ois.readObject() ).length() == 0
					? null
					: Status.valueOf( previousStatusString ),
			(Object[]) ois.readObject(),
			(Object[]) ois.readObject(),
			ois.readObject(),
			LockMode.valueOf( (String) ois.readObject() ),
			ois.readBoolean(),
			ois.readBoolean(),
			persistenceContext
	);
}
 
Example 2
Source File: ImmutableEntityEntry.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Custom deserialization routine used during deserialization of a
 * Session/PersistenceContext for increased performance.
 *
 * @param ois The stream from which to read the entry.
 * @param persistenceContext The context being deserialized.
 *
 * @return The deserialized EntityEntry
 *
 * @throws java.io.IOException If a stream error occurs
 * @throws ClassNotFoundException If any of the classes declared in the stream
 * cannot be found
 */
public static EntityEntry deserialize(
		ObjectInputStream ois,
		PersistenceContext persistenceContext) throws IOException, ClassNotFoundException {
	String previousStatusString;
	return new ImmutableEntityEntry(
			persistenceContext.getSession().getFactory(),
			(String) ois.readObject(),
			(Serializable) ois.readObject(),
			Status.valueOf( (String) ois.readObject() ),
			( previousStatusString = (String) ois.readObject() ).length() == 0
					? null
					: Status.valueOf( previousStatusString ),
			(Object[]) ois.readObject(),
			(Object[]) ois.readObject(),
			ois.readObject(),
			LockMode.valueOf( (String) ois.readObject() ),
			ois.readBoolean(),
			ois.readBoolean(),
			null
	);
}
 
Example 3
Source File: LockModeTypeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static LockMode interpretLockMode(Object value) {
	if ( value == null ) {
		return LockMode.NONE;
	}
	if ( LockMode.class.isInstance( value ) ) {
		return (LockMode) value;
	}
	else if ( LockModeType.class.isInstance( value ) ) {
		return getLockMode( (LockModeType) value );
	}
	else if ( String.class.isInstance( value ) ) {
		// first try LockMode name
		LockMode lockMode = LockMode.valueOf( (String) value );
		if ( lockMode == null ) {
			try {
				lockMode = getLockMode( LockModeType.valueOf( (String) value ) );
			}
			catch ( Exception ignore ) {
			}
		}
		if ( lockMode != null ) {
			return lockMode;
		}
	}

	throw new IllegalArgumentException( "Unknown lock mode source : " + value );
}