FileDocCategorySizeDatePackage
Assigned.javaAPI DocHibernate 3.2.51311Wed May 25 22:58:24 BST 2005org.hibernate.id

Assigned

public class Assigned extends Object implements Configurable, IdentifierGenerator
assigned

An IdentifierGenerator that returns the current identifier assigned to an instance.
author
Gavin King

Fields Summary
private String
entityName
Constructors Summary
Methods Summary
public voidconfigure(org.hibernate.type.Type type, java.util.Properties params, org.hibernate.dialect.Dialect d)

		entityName = params.getProperty(ENTITY_NAME);
		if (entityName==null) {
			throw new MappingException("no entity name");
		}
	
public java.io.Serializablegenerate(org.hibernate.engine.SessionImplementor session, java.lang.Object obj)

		
		final Serializable id = session.getEntityPersister( entityName, obj ) 
				//TODO: cache the persister, this shows up in yourkit
				.getIdentifier( obj, session.getEntityMode() );
		
		if (id==null) {
			throw new IdentifierGenerationException(
				"ids for this class must be manually assigned before calling save(): " + 
				entityName
			);
		}
		
		return id;