Java 类org.hibernate.id.Assigned 实例源码

项目:lams    文件:AbstractEntityTuplizer.java   
@Override
public void resetIdentifier(
        Object entity,
        Serializable currentId,
        Object currentVersion,
        SessionImplementor session) {
    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 )
            );
        }
    }
}
项目:lams    文件:DefaultIdentifierGeneratorFactory.java   
/**
 * Constructs a new DefaultIdentifierGeneratorFactory.
 */
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( "hilo", TableHiLoGenerator.class );
    register( "assigned", Assigned.class );
    register( "identity", IdentityGenerator.class );
    register( "select", SelectGenerator.class );
    register( "sequence", SequenceGenerator.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 );
}
项目:cacheonix-core    文件:AbstractEntityTuplizer.java   
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;
    }
}
项目:dockyard-controller    文件:NewMetadataBuilder.java   
private String getGeneratorType(AbstractEntityPersister entityPersister) {

        String generatorType = null;

        IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null;
        if (generator != null) {
            if (generator instanceof IdentityGenerator)
                generatorType = "Identity";
            else if (generator instanceof Assigned)
                generatorType = "None";
            else
                generatorType = "KeyGenerator";
        }

        return generatorType;

    }
项目:breeze.server.java    文件:HibernateMetadata.java   
/**
 * Add the metadata for an entity.
 * 
 * @param meta
 */
void addClass(ClassMetadata meta) {
    Class type = meta.getMappedClass();

    String classKey = getEntityTypeName(type);
    HashMap<String, Object> cmap = new LinkedHashMap<String, Object>();
    _typeList.add(cmap);

    cmap.put("shortName", type.getSimpleName());
    cmap.put("namespace", type.getPackage().getName());

    EntityMetamodel metaModel = ((EntityPersister) meta).getEntityMetamodel();
    String superTypeName = metaModel.getSuperclass();
    if (superTypeName != null) {
        ClassMetadata superMeta = _sessionFactory.getClassMetadata(superTypeName);
        if (superMeta != null) {
            Class superClass = superMeta.getMappedClass();
            cmap.put("baseTypeName", getEntityTypeName(superClass));
        }
    }

    String genType = "None";
    if (meta instanceof EntityPersister) {
        EntityPersister entityPersister = (EntityPersister) meta;
        // multipart keys can never have an AutoGeneratedKeyType
        if (entityPersister.hasIdentifierProperty()) {
            IdentifierGenerator generator = entityPersister != null
                    ? entityPersister.getIdentifierGenerator()
                    : null;
            if (generator != null) {
                if (generator instanceof IdentityGenerator) {
                    genType = "Identity";
                } else if (generator instanceof Assigned || generator instanceof ForeignGenerator) {
                    genType = "None";
                } else {
                    genType = "KeyGenerator";
                }
                // TODO find the real generator
            }
        }
    }
    cmap.put("autoGeneratedKeyType", genType);

    String resourceName = pluralize(type.getSimpleName()); // TODO find the real name
    cmap.put("defaultResourceName", resourceName);
    _resourceMap.put(resourceName, classKey);

    ArrayList<HashMap<String, Object>> dataArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("dataProperties", dataArrayList);
    ArrayList<HashMap<String, Object>> navArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("navigationProperties", navArrayList);

    addClassProperties(meta, dataArrayList, navArrayList);
}
项目:dockyard-controller    文件:MetadataBuilder.java   
/**
 * Add the metadata for an entity.
 * @param meta
 */
void addClass(ClassMetadata meta) {

    Class type = meta.getMappedClass();

    String classKey = getEntityTypeName(type);
    HashMap<String, Object> cmap = new LinkedHashMap<String, Object>();
    typeList.add(cmap);

    cmap.put("shortName", type.getSimpleName());
    cmap.put("namespace", type.getPackage().getName());

    if (meta instanceof AbstractEntityPersister) {

        AbstractEntityPersister entityPersister = (AbstractEntityPersister) meta;
        String superClassEntityName = entityPersister.getMappedSuperclass();

        if (superClassEntityName != null) {
            Class superType = this.sessionFactory.getClassMetadata(superClassEntityName).getMappedClass();
            String baseTypeName = this.getEntityTypeName(superType);
            cmap.put("baseTypeName", baseTypeName);
        }

        IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null;
        if (generator != null) {
            String genType = null;

            if (generator instanceof IdentityGenerator)
                genType = "Identity";
            else if (generator instanceof Assigned)
                genType = "None";
            else
                genType = "KeyGenerator";

            cmap.put("autoGeneratedKeyType", genType); // TODO find the real generator
        }
    }


    String resourceName = pluralize(type.getSimpleName()); // TODO find the real name
    cmap.put("defaultResourceName", resourceName);
    resourceMap.put(resourceName, classKey);

    ArrayList<HashMap<String, Object>> dataArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("dataProperties", dataArrayList);

    ArrayList<HashMap<String, Object>> navArrayList = new ArrayList<HashMap<String, Object>>();
    cmap.put("navigationProperties", navArrayList);

    try {
        this.addClassProperties(meta, dataArrayList, navArrayList);
    } catch (Exception e) {
        e.printStackTrace();
    }
}