本文整理汇总了Java中org.hibernate.persister.entity.AbstractEntityPersister类的典型用法代码示例。如果您正苦于以下问题:Java AbstractEntityPersister类的具体用法?Java AbstractEntityPersister怎么用?Java AbstractEntityPersister使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractEntityPersister类属于org.hibernate.persister.entity包,在下文中一共展示了AbstractEntityPersister类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixCompositeIdentifierInMetaModel
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
private static void fixCompositeIdentifierInMetaModel(SessionFactory sessionFactory, Class clazz) {
ClassMetadata classMetadata = sessionFactory.getClassMetadata(clazz);
if (classMetadata instanceof AbstractEntityPersister) {
AbstractEntityPersister persister = (AbstractEntityPersister) classMetadata;
EntityMetamodel model = persister.getEntityMetamodel();
IdentifierProperty identifier = model.getIdentifierProperty();
try {
Field field = IdentifierProperty.class.getDeclaredField("hasIdentifierMapper");
field.setAccessible(true);
field.set(identifier, true);
field.setAccessible(false);
} catch (Exception ex) {
throw new SystemException("Attempt to fix entity meta model with hack failed, reason: "
+ ex.getMessage(), ex);
}
}
}
示例2: buildSimpleEncapsulatedIdentifierDefinition
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
public static EntityIdentifierDefinition buildSimpleEncapsulatedIdentifierDefinition(final AbstractEntityPersister entityPersister) {
return new EncapsulatedEntityIdentifierDefinition() {
private final AttributeDefinitionAdapter attr = new AttributeDefinitionAdapter( entityPersister);
@Override
public AttributeDefinition getAttributeDefinition() {
return attr;
}
@Override
public boolean isEncapsulated() {
return true;
}
@Override
public EntityDefinition getEntityDefinition() {
return entityPersister;
}
};
}
示例3: buildEncapsulatedCompositeIdentifierDefinition
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
public static EntityIdentifierDefinition buildEncapsulatedCompositeIdentifierDefinition(
final AbstractEntityPersister entityPersister) {
return new EncapsulatedEntityIdentifierDefinition() {
private final CompositionDefinitionAdapter compositionDefinition = new CompositionDefinitionAdapter( entityPersister );
@Override
public AttributeDefinition getAttributeDefinition() {
return compositionDefinition;
}
@Override
public boolean isEncapsulated() {
return true;
}
@Override
public EntityDefinition getEntityDefinition() {
return entityPersister;
}
};
}
示例4: truncate
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
@Transactional
public void truncate() throws Exception {
List<String> tableNames = new ArrayList<>();
Session session = entityManager.unwrap(Session.class);
Map<String, ClassMetadata> hibernateMetadata = session.getSessionFactory().getAllClassMetadata();
for (ClassMetadata classMetadata : hibernateMetadata.values()) {
AbstractEntityPersister aep = (AbstractEntityPersister) classMetadata;
tableNames.add(aep.getTableName());
}
entityManager.flush();
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate();
tableNames.forEach(tableName -> entityManager.createNativeQuery("TRUNCATE TABLE " + tableName).executeUpdate());
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY TRUE").executeUpdate();
}
示例5: getColumns
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* REVISAR NIKOLAS
*/
@Override
public String[] getColumns(
String propertyName,
Criteria subcriteria) throws HibernateException {
// return getPropertyMapping( getEntityName( subcriteria, propertyName ) )
// .toColumns(
// getSQLAlias( subcriteria, propertyName ),
// getPropertyName( propertyName )
// );
String alias = getSQLAlias( subcriteria, propertyName );
String property = getPropertyName( propertyName );
String _root = AbstractEntityPersister.generateTableAlias(
alias,
0
);
return new String[]{_root+"."+property};
}
示例6: getAllDbMetaData
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
public HealthInfoDTO getAllDbMetaData() {
List<TableInfoDTO> tables = new ArrayList<>();
try {
Map<String, ClassMetadata> map = saudeDao.getAllDbMetaData();
map.forEach((k, v) -> tables.add(getTableInfo((AbstractEntityPersister) v)));
Optional<IValidatorDatabase> validator = verificaDialetoUtilizado();
if (validator.isPresent()) {
validator.get().checkAllInfoTable(tables);
}
} catch (Exception e) {
getLogger().error(e.getMessage(), e);
tables.clear();
}
return new HealthInfoDTO(tables);
}
示例7: getTableInfo
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
private TableInfoDTO getTableInfo(AbstractEntityPersister persister) {
TableInfoDTO tableInfoDTO = new TableInfoDTO();
String[] name = SqlUtil.replaceSingularSchemaName(persister.getTableName()).split("\\.");
tableInfoDTO.setSchema(name[0]);
tableInfoDTO.setTableName(name[1]);
List<String> columns = new ArrayList<>();
String[] propertyNames = persister.getPropertyNames();
Arrays.asList(propertyNames).forEach(propertyName ->
columns.add(persister.getPropertyColumnNames(propertyName)[0]));
Arrays.asList(persister.getIdentifierColumnNames()).forEach(chave -> {
if (!columns.contains(chave)) {
columns.add(chave);
}
});
List<ColumnInfoDTO> columnsType = new ArrayList<>();
columns.forEach(col -> columnsType.add(new ColumnInfoDTO(col, true)));
tableInfoDTO.setColumnsInfo(columnsType);
return tableInfoDTO;
}
示例8: getProperties
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* @see org.tools.hqlbuilder.common.HqlService#getProperties(java.lang.String)
*/
@Override
public List<String> getProperties(String classname) {
if (StringUtils.isBlank(classname)) {
throw new IllegalArgumentException("classname");
}
Map<String, ?> allClassMetadata = new MetadataResolver().getAllClassMetadata(sessionFactory);
Object classMeta = allClassMetadata.get(classname);
if (classMeta == null) {
return null;
}
List<String> propertyNames = new ArrayList<>(Arrays.asList(AbstractEntityPersister.class.cast(classMeta).getPropertyNames()));
propertyNames.remove("id");
propertyNames.remove("version");
return propertyNames;
}
示例9: onPreLoad
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* Diese Methode lädt die Daten um eine Tabelle zu erzeugen.
*/
@Override
public void onPreLoad(PreLoadEvent preLoadEvent) {
//System.out.println("onPreLoad ausgelöst");
Serializable id = preLoadEvent.getId();
Object[] values = preLoadEvent.getState();
persister = (AbstractEntityPersister)preLoadEvent.getPersister();
//virtuelle Table aufbauen
List<Row> rows = new ArrayList();
List<ColumnDescriptor> columnDescriptors = new ArrayList();
List<Column> columns = new ArrayList();
columnDescriptors.add(addIdentifierToColumns(columns, id));
columnDescriptors.addAll(addPropertiesToColumns(columns, values));
Row row = new Row(columns);
rows.add(row);
//Ergebnisse holen und in values verfrachten
//System.out.println("Erzeuge virtuelle Tabelle: " + persister.getRootTableName());
Table table = new Table(persister.getRootTableName(), rows, columnDescriptors);
TableReader reader = new TableReader();
table = reader.select(table);
setValuesFromRow(table.getRows().get(0), values);
}
示例10: getSuperProperties
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* Return names of all properties that are defined in the mapped ancestors of the given
* persister. Note that unmapped superclasses are deliberately ignored, because they shouldn't
* affect the metadata.
*
* @param persister
* @return set of property names. Empty if the persister doesn't have a superclass.
*/
HashSet<String> getSuperProperties(AbstractEntityPersister persister) {
HashSet<String> set = new HashSet<String>();
String superClassName = persister.getMappedSuperclass();
if (superClassName == null)
return set;
ClassMetadata superMeta = _sessionFactory.getClassMetadata(superClassName);
if (superMeta == null)
return set;
String[] superProps = superMeta.getPropertyNames();
set.addAll(Arrays.asList(superProps));
set.add(superMeta.getIdentifierPropertyName());
return set;
}
示例11: getPropertyColumnNames
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* Get the column names for a given property as an array of unbracketed,
* lowercase names. For a collection property, the column name is the inverse foreign key (i.e.
* the column on the other table that points back to the persister's table)
*/
String[] getPropertyColumnNames(AbstractEntityPersister persister, String propertyName, Type propType) {
String[] propColumnNames = null;
if (propType.isCollectionType()) {
propColumnNames = ((CollectionType) propType).getAssociatedJoinable((SessionFactoryImplementor) this._sessionFactory)
.getKeyColumnNames();
} else {
propColumnNames = persister.getPropertyColumnNames(propertyName);
}
if (propColumnNames == null || propColumnNames.length == 0) {
// this happens when the property is part of the key
propColumnNames = persister.getKeyColumnNames();
}
// HACK for formula: when using formula propColumnNames[0] equals null
if (propColumnNames[0] == null)
{
propColumnNames = new String[] { propertyName };
}
return unBracket(propColumnNames);
}
示例12: getGeneratorType
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
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;
}
示例13: getIdentifierSubAttributes
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
/**
* Get composite ID sub-attribute definitions.
*
* @param entityPersister - the entity persister.
*
* @return composite ID sub-attribute definitions.
*/
public static Iterable<AttributeDefinition> getIdentifierSubAttributes(AbstractEntityPersister entityPersister) {
return getSingularSubAttributes(
entityPersister,
entityPersister,
(CompositeType) entityPersister.getIdentifierType(),
entityPersister.getTableName(),
entityPersister.getRootTableIdentifierColumnNames()
);
}
示例14: getAlias
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
@Override
public String getAlias(String table) {
if (table == null){
return rootAlias;
} else{
return AbstractEntityPersister.generateTableAlias(rootAlias, AbstractEntityPersister.getTableId(table, tables));
}
}
示例15: loadSystemTableList
import org.hibernate.persister.entity.AbstractEntityPersister; //导入依赖的package包/类
private void loadSystemTableList(SessionFactory sessionFactory) {
Map<String, ClassMetadata> allClassMetadata = sessionFactory.getAllClassMetadata();
allClassMetadata.forEach((key, value) -> {
AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) value;
SYSTEM_TABLE_LIST.add(abstractEntityPersister.getTableName());
});
}