org.hibernate.id.Assigned Java Examples

The following examples show how to use org.hibernate.id.Assigned. 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: AbstractEntityTuplizer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void resetIdentifier(
		Object entity,
		Serializable currentId,
		Object currentVersion,
		SharedSessionContractImplementor session) {
	//noinspection StatementWithEmptyBody
	if ( entityMetamodel.getIdentifierProperty().getIdentifierGenerator() instanceof Assigned ) {
	}
	else {
		//reset the id
		Serializable result = entityMetamodel.getIdentifierProperty()
				.getUnsavedValue()
				.getDefaultValue( currentId );
		setIdentifier( entity, result, session );
		//reset the version
		VersionProperty versionProperty = entityMetamodel.getVersionProperty();
		if ( entityMetamodel.isVersioned() ) {
			setPropertyValue(
					entity,
					entityMetamodel.getVersionPropertyIndex(),
					versionProperty.getUnsavedValue().getDefaultValue( currentVersion )
			);
		}
	}
}
 
Example #2
Source File: DefaultIdentifierGeneratorFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new DefaultIdentifierGeneratorFactory.
 */
@SuppressWarnings("deprecation")
public DefaultIdentifierGeneratorFactory() {
	register( "uuid2", UUIDGenerator.class );
	register( "guid", GUIDGenerator.class );			// can be done with UUIDGenerator + strategy
	register( "uuid", UUIDHexGenerator.class );			// "deprecated" for new use
	register( "uuid.hex", UUIDHexGenerator.class ); 	// uuid.hex is deprecated
	register( "assigned", Assigned.class );
	register( "identity", IdentityGenerator.class );
	register( "select", SelectGenerator.class );
	register( "sequence", SequenceStyleGenerator.class );
	register( "seqhilo", SequenceHiLoGenerator.class );
	register( "increment", IncrementGenerator.class );
	register( "foreign", ForeignGenerator.class );
	register( "sequence-identity", SequenceIdentityGenerator.class );
	register( "enhanced-sequence", SequenceStyleGenerator.class );
	register( "enhanced-table", TableGenerator.class );
}
 
Example #3
Source File: AbstractEntityTuplizer.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void resetIdentifier(Object entity, Serializable currentId, Object currentVersion) {
	if ( entityMetamodel.getIdentifierProperty().getIdentifierGenerator() instanceof Assigned ) {
		//return currentId;
	}
	else {
		//reset the id
		Serializable result = entityMetamodel.getIdentifierProperty()
				.getUnsavedValue()
				.getDefaultValue( currentId );
		setIdentifier( entity, result );
		//reset the version
		VersionProperty versionProperty = entityMetamodel.getVersionProperty();
		if ( entityMetamodel.isVersioned() ) {
			setPropertyValue(
			        entity,
			        entityMetamodel.getVersionPropertyIndex(),
					versionProperty.getUnsavedValue().getDefaultValue( currentVersion )
				);
		}
		//return the id, so we can use it to reset the proxy id
		//return result;
	}
}