本文整理了Java中org.hibernate.cfg.Configuration.getTableMappings()
方法的一些代码示例,展示了Configuration.getTableMappings()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getTableMappings()
方法的具体详情如下:
包路径:org.hibernate.cfg.Configuration
类名称:Configuration
方法名:getTableMappings
[英]Iterate the table mappings
[中]迭代表映射
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
public Iterator getTableMappings() {
return cfg.getTableMappings();
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public Set getJbpmTables() {
Set jbpmTables = new HashSet();
for (Iterator i = configuration.getTableMappings(); i.hasNext();) {
Table table = (Table) i.next();
if (table.isPhysicalTable()) {
jbpmTables.add(table.getName());
}
}
return jbpmTables;
}
代码示例来源:origin: com.vecna/dbDiff-hibernate
/**
* Convert Hibernate mappings to DbDiff RelationalDatabase
* @return a RelationalDatabase representation of the hibernate mappings
*/
public RelationalDatabase convert() {
List<RelationalTable> tables = new ArrayList<>();
Iterator<org.hibernate.mapping.Table> mappedTables = m_configuration.getTableMappings();
while (mappedTables.hasNext()) {
tables.add(convertTable(mappedTables.next()));
}
return new RelationalDatabase(tables);
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
private Table findTableMapping(String tableName) {
for (Iterator i = configuration.getTableMappings(); i.hasNext();) {
Table table = (Table) i.next();
if (tableName.equals(table.getName())) return table;
}
throw new JbpmException("no mapping found for table: " + tableName);
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.persistence.transform-asl
Iterator<Table> iter = cfg.getTableMappings();
while (iter.hasNext())
dropSQL.add("DROP TABLE " + iter.next().getName());
代码示例来源:origin: hibernate/hibernate
iter = getTableMappings();
Set done = new HashSet();
while ( iter.hasNext() ) secondPassCompileForeignKeys( ( Table ) iter.next(), done );
代码示例来源:origin: hibernate/hibernate
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
Table table = ( Table ) iter.next();
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
itr = getTableMappings();
Set<ForeignKey> done = new HashSet<ForeignKey>();
while ( itr.hasNext() ) {
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
itr = getTableMappings();
Set<ForeignKey> done = new HashSet<ForeignKey>();
while ( itr.hasNext() ) {
代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.persistence.transform-asl
public static void truncateTables(final DBConfig dbConfig) {
System.out.println("TRUNCATE TABLES");
Configuration cfg = HibernateConnect.getConfiguration(dbConfig);
SessionFactory sf = cfg.buildSessionFactory(
new ServiceRegistryBuilder().applySettings(
cfg.getProperties()).buildServiceRegistry());
Session session = sf.openSession();
try {
session.createSQLQuery("SET FOREIGN_KEY_CHECKS=0").executeUpdate();
Iterator<Table> iter = cfg.getTableMappings();
while (iter.hasNext())
session.createSQLQuery("TRUNCATE TABLE " + iter.next().getName()).executeUpdate();
} finally {
session.createSQLQuery("SET FOREIGN_KEY_CHECKS=1").executeUpdate();
session.disconnect();
session.close();
}
}
代码示例来源:origin: org.beangle.commons/beangle-commons-orm
public String validateSchema(Configuration config, Dialect dialect, DatabaseMetadata databaseMetadata) {
String defaultCatalog = sessionFactoryBean.getHibernateProperties().getProperty(
Environment.DEFAULT_CATALOG);
String defaultSchema = sessionFactoryBean.getHibernateProperties()
.getProperty(Environment.DEFAULT_SCHEMA);
Mapping mapping = config.buildMapping();
Iterator<?> iter = config.getTableMappings();
while (iter.hasNext()) {
Table table = (Table) iter.next();
if (table.isPhysicalTable()) {
TableMetadata tableInfo = databaseMetadata.getTableMetadata(table.getName(),
(table.getSchema() == null) ? defaultSchema : table.getSchema(),
(table.getCatalog() == null) ? defaultCatalog : table.getCatalog(), table.isQuoted());
if (tableInfo == null) {
reporter.append("Missing table: " + table.getName() + "\n");
} else {
validateColumns(table, dialect, mapping, tableInfo);
}
}
}
iter = iterateGenerators(config, dialect);
while (iter.hasNext()) {
PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
Object key = generator.generatorKey();
if (!databaseMetadata.isSequence(key) && !databaseMetadata.isTable(key)) { throw new HibernateException(
"Missing sequence or table: " + key); }
}
return null;
}
代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate
+ "initialized.table"));
} else {
for (final Iterator iter = configuration.getTableMappings(); iter.hasNext();) {
Table t = (Table) iter.next();
if (t.isPhysicalTable()) {
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)throws HibernateException {
secondPassCompile();
String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
table.isQuoted());
if ( tableInfo == null ) {
throw new HibernateException( "Missing table: " + table.getName() );
}
else {
table.validateColumns( dialect, mapping, tableInfo );
}
}
}
iter = iterateGenerators( dialect );
while ( iter.hasNext() ) {
PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
Object key = generator.generatorKey();
if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
throw new HibernateException( "Missing sequence or table: " + key );
}
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)throws HibernateException {
secondPassCompile();
String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
Iterator iter = getTableMappings();
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
table.isQuoted());
if ( tableInfo == null ) {
throw new HibernateException( "Missing table: " + table.getName() );
}
else {
table.validateColumns( dialect, mapping, tableInfo );
}
}
}
iter = iterateGenerators( dialect );
while ( iter.hasNext() ) {
PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
Object key = generator.generatorKey();
if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
throw new HibernateException( "Missing sequence or table: " + key );
}
}
}
代码示例来源:origin: Blazebit/blaze-persistence
serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(configuration.getTableMappings(), sessionFactory.getDialect(), new SimpleTableNameFormatter(), configuration.buildMapping()));
代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-4.3
@Override
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
Class<?> valuesEntity;
boolean registerValuesEntity = true;
try {
valuesEntity = Class.forName("com.blazebit.persistence.impl.function.entity.ValuesEntity");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Are you missing blaze-persistence-core-impl on the classpath?", e);
}
Iterator<PersistentClass> iter = configuration.getClassMappings();
while (iter.hasNext()) {
PersistentClass clazz = iter.next();
Class<?> entityClass = clazz.getMappedClass();
if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
}
}
if (registerValuesEntity) {
// Register values entity if wasn't found
configuration.addAnnotatedClass(valuesEntity);
configuration.buildMappings();
PersistentClass clazz = configuration.getClassMapping(valuesEntity.getName());
clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
}
serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(configuration.getTableMappings(), sessionFactory.getDialect(), new SimpleTableNameFormatter(), configuration.buildMapping()));
}
代码示例来源:origin: Blazebit/blaze-persistence
@Override
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
Class<?> valuesEntity;
boolean registerValuesEntity = true;
try {
valuesEntity = Class.forName("com.blazebit.persistence.impl.function.entity.ValuesEntity");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Are you missing blaze-persistence-core-impl on the classpath?", e);
}
Iterator<PersistentClass> iter = configuration.getClassMappings();
while (iter.hasNext()) {
PersistentClass clazz = iter.next();
Class<?> entityClass = clazz.getMappedClass();
if (entityClass != null && entityClass.isAnnotationPresent(CTE.class)) {
clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
}
}
if (registerValuesEntity) {
// Register values entity if wasn't found
configuration.addAnnotatedClass(valuesEntity);
configuration.buildMappings();
PersistentClass clazz = configuration.getClassMapping(valuesEntity.getName());
clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName());
}
serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver());
serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(configuration.getTableMappings(), sessionFactory.getDialect(), new SimpleTableNameFormatter(), configuration.buildMapping()));
}
代码示例来源:origin: jhipster/jhipster-loaded
@Override
protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException {
if (!snapshot.getSnapshotControl().shouldInclude(Table.class)) {
return;
}
if (foundObject instanceof Schema) {
Schema schema = (Schema) foundObject;
HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase();
Configuration cfg = database.getConfiguration();
Iterator<org.hibernate.mapping.Table> tableMappings = cfg.getTableMappings();
while (tableMappings.hasNext()) {
org.hibernate.mapping.Table hibernateTable = tableMappings.next();
if (hibernateTable.isPhysicalTable()) {
Table table = new Table().setName(hibernateTable.getName());
table.setSchema(schema);
LOG.info("Found table " + table.getName());
schema.addDatabaseObject(table);
}
}
}
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
dschema = config.getProperty(Environment.DEFAULT_SCHEMA);
config.setProperty(Environment.DEFAULT_SCHEMA, contextSchema);
Iterator iter = config.getTableMappings();
while (iter.hasNext()) {
Table table = (Table) iter.next();
内容来源于网络,如有侵权,请联系作者删除!