Search in sources :

Example 1 with Mapping

use of org.hibernate.engine.Mapping in project xwiki-platform by xwiki.

the class AbstractDropNotNullDataMigration method getLiquibaseChangeLog.

@Override
public String getLiquibaseChangeLog() throws DataMigrationException {
    XWikiHibernateBaseStore store = getStore();
    Dialect dialect = store.getDialect();
    Configuration configuration = store.getConfiguration();
    Mapping mapping = configuration.buildMapping();
    PersistentClass pClass = configuration.getClassMapping(this.table.getName());
    Column column = ((Column) pClass.getProperty(this.property).getColumnIterator().next());
    String columnType = column.getSqlType(dialect, mapping);
    StringBuilder builder = new StringBuilder();
    builder.append("<changeSet author=\"xwiki\" id=\"R").append(this.getVersion().getVersion()).append("\">\n");
    builder.append("    <dropNotNullConstraint\n");
    builder.append("            columnDataType=\"").append(columnType).append('"').append('\n');
    builder.append("            columnName=\"").append(column.getName()).append('"').append('\n');
    builder.append("            tableName=\"").append(pClass.getTable().getName()).append("\"/>\n");
    builder.append("</changeSet>");
    return builder.toString();
}
Also used : Configuration(org.hibernate.cfg.Configuration) Column(org.hibernate.mapping.Column) Dialect(org.hibernate.dialect.Dialect) Mapping(org.hibernate.engine.Mapping) XWikiHibernateBaseStore(com.xpn.xwiki.store.XWikiHibernateBaseStore) PersistentClass(org.hibernate.mapping.PersistentClass)

Aggregations

XWikiHibernateBaseStore (com.xpn.xwiki.store.XWikiHibernateBaseStore)1 Configuration (org.hibernate.cfg.Configuration)1 Dialect (org.hibernate.dialect.Dialect)1 Mapping (org.hibernate.engine.Mapping)1 Column (org.hibernate.mapping.Column)1 PersistentClass (org.hibernate.mapping.PersistentClass)1