当前位置: 首页>>代码示例>>Java>>正文


Java PrimaryKey.setName方法代码示例

本文整理汇总了Java中org.hibernate.mapping.PrimaryKey.setName方法的典型用法代码示例。如果您正苦于以下问题:Java PrimaryKey.setName方法的具体用法?Java PrimaryKey.setName怎么用?Java PrimaryKey.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.mapping.PrimaryKey的用法示例。


在下文中一共展示了PrimaryKey.setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: normalizePrimaryKeys

import org.hibernate.mapping.PrimaryKey; //导入方法依赖的package包/类
private void normalizePrimaryKeys(Table table, String entityName) {
	PrimaryKey pk = table.getPrimaryKey();
	if (pk != null) {
		String name = strategy.primaryKeyName(entityName, table.getName());
		pk.setName(name);
	}
}
 
开发者ID:andreluiznsilva,项目名称:hibernate-conventions,代码行数:8,代码来源:MappingConventions.java

示例2: createPKComposite

import org.hibernate.mapping.PrimaryKey; //导入方法依赖的package包/类
protected void createPKComposite(Mappings mappings,
                                 com.manydesigns.portofino.model.database.Table mdTable,
                                 String pkName, RootClass clazz,
                                 Table tab,
                                 List<com.manydesigns.portofino.model.database.Column> columnPKList) {


    PrimaryKey primaryKey = new PrimaryKey();
    primaryKey.setName(pkName);
    primaryKey.setTable(tab);

    clazz.setEmbeddedIdentifier(true);
    Component component = new Component(mappings, clazz);
    component.setDynamic(mdTable.getActualJavaClass()==null);
    String name;
    name = mdTable.getQualifiedName();

    component.setRoleName(name + ".id");
    component.setEmbedded(true);
    //component.setNodeName("id");
    component.setKey(true);
    component.setNullValue("undefined");

    if (!component.isDynamic()){
        component.setComponentClassName
                (mdTable.getJavaClass()); //TODO verificare se non si intende actualJavaClass
    }

    boolean hasErrors = false;
    for (com.manydesigns.portofino.model.database.Column
            column : columnPKList) {
        if (column == null ) {
            throw new InternalError("Null column");
        }

        Column col = createColumn(mappings, tab, column);

        hasErrors = col == null || hasErrors;

        if(col != null) {
            primaryKey.addColumn(col);
            Property prop = createProperty(column, col.getValue());
            prop.setCascade("none");
            //prop.setPropertyAccessorName("property"); interferisce con il generator più sotto
            prop.setPersistentClass(clazz);
            component.addProperty(prop);

            //Generator not supported for embedded map identifier
            //See https://forum.hibernate.org/viewtopic.php?t=945273
            //See Component.buildIdentifierGenerator()
            /*String columnName = column.getColumnName();
            PrimaryKeyColumn pkCol = mdTable.getPrimaryKey().findPrimaryKeyColumnByName(columnName);
            if(pkCol == null) {
                logger.error("Column without corresponding PrimaryKeyColumn: {}", columnName);
                hasErrors = true;
                continue;
            }
            Generator generator = pkCol.getGenerator();
            setPKColumnGenerator(mappings, clazz, tab, column, value, generator);*/
        }
    }
    if (hasErrors) {
        // TODO : se la PK non e' buona, tutta la tabella dovrebbe saltare
        logger.error("Table "+name+": Skipping primary key");
        return;
    }

    tab.setIdentifierValue(component);
    clazz.setIdentifier(component);
    clazz.setDiscriminatorValue(name);

    tab.setPrimaryKey(primaryKey);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:74,代码来源:HibernateConfig.java

示例3: createPKSingle

import org.hibernate.mapping.PrimaryKey; //导入方法依赖的package包/类
protected void createPKSingle(Mappings mappings,
                              com.manydesigns.portofino.model.database.Table mdTable,
                              String pkName, RootClass clazz,
                              Table tab,
                              List<com.manydesigns.portofino.model.database.Column> columnPKList) {
    PrimaryKeyColumn pkcol = mdTable.getPrimaryKey().getPrimaryKeyColumns().get(0);
    com.manydesigns.portofino.model.database.Column column = columnPKList.get(0);
    final PrimaryKey primaryKey = new PrimaryKey();
    primaryKey.setName(pkName); //TODO quote?
    primaryKey.setTable(tab);
    tab.setPrimaryKey(primaryKey);

    Column col = createColumn(mappings, tab, column);

    if (col == null) {
        // TODO : se la PK non e' buona, tutta la tabella dovrebbe saltare
        logger.error("Skipping primary key "+pkName);
        return;
    }

    SimpleValue id = (SimpleValue) col.getValue();
    //Make the defaults explicit. See section 5.1.4.5. Assigned identifiers in the Hibernate reference
    //(http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html)
    id.setIdentifierGeneratorStrategy("assigned");
    id.setNullValue("undefined");

    tab.getPrimaryKey().addColumn(col);
    
    Property prop = createProperty(column, id);
    clazz.addProperty(prop);
    prop.setPropertyAccessorName(mappings.getDefaultAccess());

    prop.setInsertable(false);
    prop.setUpdateable(false);

    Generator generator = pkcol.getGenerator();

    setPKColumnGenerator(mappings, clazz, tab, column, id, generator);

    tab.setIdentifierValue(id);
    clazz.setIdentifier(id);
    clazz.setIdentifierProperty(prop);
    clazz.setDiscriminatorValue(mdTable.getQualifiedName());

}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:46,代码来源:HibernateConfig.java

示例4: createPKComposite

import org.hibernate.mapping.PrimaryKey; //导入方法依赖的package包/类
protected void createPKComposite(Mappings mappings,
                                 com.manydesigns.portofino.model.database.Table mdTable,
                                 String pkName, RootClass clazz,
                                 Table tab,
                                 List<com.manydesigns.portofino.model.database.Column> columnPKList) {


    PrimaryKey primaryKey = new PrimaryKey();
    primaryKey.setName(pkName);
    primaryKey.setTable(tab);

    clazz.setEmbeddedIdentifier(true);
    Component component = new Component(mappings, clazz);
    component.setDynamic(mdTable.getActualJavaClass()==null);
    String name;
    name = mdTable.getQualifiedName();

    component.setRoleName(name + ".id");
    component.setEmbedded(true);
    //component.setNodeName("id");
    component.setKey(true);
    component.setNullValue("undefined");

    if (!component.isDynamic()){
        component.setComponentClassName
                (mdTable.getJavaClass()); //TODO verificare se non si intende actualJavaClass
    }

    boolean hasErrors = false;
    for (com.manydesigns.portofino.model.database.Column
            column : columnPKList) {
        if (column == null ) {
            throw new InternalError("Null column");
        }

        Column col = createColumn(mappings, tab, column);

        hasErrors = col == null || hasErrors;

        if(col != null) {
            primaryKey.addColumn(col);
            Property prop = createProperty(column, col.getValue());
            prop.setCascade("none");
            //prop.setPropertyAccessorName("property"); interferisce con il generator più sotto
            prop.setPersistentClass(clazz);
            component.addProperty(prop);

            //Generator not supported for embedded map identifier
            //See https://forum.hibernate.org/viewtopic.php?t=945273
            //See Component.buildIdentifierGenerator()
            /*String columnName = column.getColumnName();
            PrimaryKeyColumn pkCol = mdTable.getPrimaryKey().findPrimaryKeyColumnByName(columnName);
            if(pkCol == null) {
                logger.error("Column without corresponding PrimaryKeyColumn: {}", columnName);
                hasErrors = true;
                continue;
            }
            Generator generator = pkCol.getGenerator();
            setPKColumnGenerator(mappings, clazz, tab, column, value, generator);*/
        }
    }
    if (hasErrors) {
        // TODO PAOLO: se la PK non e' buona, tutta la tabella dovrebbe saltare
        logger.error("Skipping primary key");
        return;
    }

    tab.setIdentifierValue(component);
    clazz.setIdentifier(component);
    clazz.setDiscriminatorValue(name);

    tab.setPrimaryKey(primaryKey);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:74,代码来源:HibernateConfig.java

示例5: createPKSingle

import org.hibernate.mapping.PrimaryKey; //导入方法依赖的package包/类
protected void createPKSingle(Mappings mappings,
                              com.manydesigns.portofino.model.database.Table mdTable,
                              String pkName, RootClass clazz,
                              Table tab,
                              List<com.manydesigns.portofino.model.database.Column> columnPKList) {
    PrimaryKeyColumn pkcol =mdTable.getPrimaryKey().getPrimaryKeyColumns().get(0);
    com.manydesigns.portofino.model.database.Column
            column = columnPKList.get(0);
    final PrimaryKey primaryKey = new PrimaryKey();
    primaryKey.setName(pkName);
    primaryKey.setTable(tab);
    tab.setPrimaryKey(primaryKey);

    Column col = createColumn(mappings, tab, column);

    if (col == null) {
        // TODO PAOLO: se la PK non e' buona, tutta la tabella dovrebbe saltare
        logger.error("Skipping primary key");
        return;
    }

    SimpleValue id = (SimpleValue) col.getValue();
    //Make the defaults explicit. See section 5.1.4.5. Assigned identifiers in the Hibernate reference
    //(http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html)
    id.setIdentifierGeneratorStrategy("assigned");
    id.setNullValue("undefined");

    tab.getPrimaryKey().addColumn(col);
    
    Property prop = createProperty(column, id);
    clazz.addProperty(prop);
    prop.setPropertyAccessorName(mappings.getDefaultAccess());
    //PropertyGeneration generation = PropertyGeneration.parse(null);
    //prop.setGeneration(generation);

    prop.setInsertable(false);
    prop.setUpdateable(false);

    Generator generator = pkcol.getGenerator();

    setPKColumnGenerator(mappings, clazz, tab, column, id, generator);

    tab.setIdentifierValue(id);
    clazz.setIdentifier(id);
    clazz.setIdentifierProperty(prop);
    clazz.setDiscriminatorValue(mdTable.getQualifiedName());

}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:49,代码来源:HibernateConfig.java


注:本文中的org.hibernate.mapping.PrimaryKey.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。