Changeset 7367


Ignore:
Timestamp:
May 17, 2017, 9:45:10 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2084: Upgrade to Hibernate 5.2

Fixed compilation errors in DbIndexWork and SchemaGenerator. The code can now be compiled (1332 warnings) and the installation program runs without any problem.

Need to compare the generated database with one generated with the old Hibernate.

Some test program fails:

TestUser FAILED                       
TestGlobalDefaultSetting FAILED       
TestClientDefaultSetting FAILED       
TestUserDefaultSetting FAILED         
TestUserClientSetting FAILED          
TestReporter FAILED                   
TestReporterList FAILED               
TestArrayDesign FAILED                
TestRawBioAssay FAILED                
TestSpotImages FAILED                 
TestDbControl FAILED                  
TestReporterFlatFileImporter FAILED   
TestReporterMapFlatFileImporter FAILED
TestPlateFlatFileImporter FAILED      
TestRawDataFlatFileImporter FAILED    
TestPrintMapFlatFileImporter FAILED   
TestGalExporter FAILED                
TestDirty FAILED                      
TestIlluminaImporter FAILED           
TestGtfImporters FAILED               
TestBasicAnalysis FAILED              
TestReporterCloneTemplate FAILED      
TestIntensityCalculatorPlugin FAILED  
TestLowessNormalization FAILED        
TestMedianRatioNormalization FAILED   
TestBaseFileExporterImporter FAILED   
TestBfsExporterImporter FAILED        
TestBase1PluginExecuter FAILED        
TestExternalProgramExecutor FAILED    
++29 tests failed!                    
++78 tests succeeded!                 
Location:
branches/hibernate-5.2/src/core/net/sf/basedb/core/hibernate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/hibernate/DbIndexWork.java

    r7263 r7367  
    3939import org.hibernate.jdbc.Work;
    4040import org.hibernate.mapping.Table;
    41 import org.hibernate.tool.schema.spi.Target;
     41import org.hibernate.tool.schema.spi.ScriptTargetOutput;
    4242
    4343import net.sf.basedb.core.BaseException;
     
    7070  private final boolean dropIndexes;
    7171  private final boolean updateIndexes;
    72   private Target target;
     72  private ScriptTargetOutput target;
    7373 
    7474  public DbIndexWork(Metadata metadata, Dialect dialect, DbEngine dbEngine,
     
    8989    statements that are needed to create missing foreign keys
    9090    and indexes.
    91     @since 3.8
     91    @since 3.8 and 3.11
    9292  */
    93   public void setTarget(Target target)
     93  public void setTarget(ScriptTargetOutput target)
    9494  {
    9595    this.target = target;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/hibernate/SchemaGenerator.java

    r7150 r7367  
    2626import java.sql.Statement;
    2727import java.util.ArrayList;
    28 import java.util.Arrays;
     28import java.util.Collections;
     29import java.util.EnumSet;
    2930import java.util.List;
     31import java.util.Map;
    3032
    3133import net.sf.basedb.core.ProgressReporter;
     
    3537
    3638import org.hibernate.boot.Metadata;
    37 import org.hibernate.boot.model.relational.Namespace;
    3839import org.hibernate.boot.spi.MetadataImplementor;
    3940import org.hibernate.dialect.Dialect;
    40 import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
    41 import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
    42 import org.hibernate.engine.jdbc.spi.JdbcServices;
    4341import org.hibernate.jdbc.Work;
    4442import org.hibernate.service.ServiceRegistry;
    45 import org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl;
    46 import org.hibernate.tool.schema.extract.spi.DatabaseInformation;
     43import org.hibernate.service.spi.ServiceRegistryImplementor;
     44import org.hibernate.tool.schema.SourceType;
     45import org.hibernate.tool.schema.TargetType;
    4746import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
    48 import org.hibernate.tool.schema.internal.SchemaMigratorImpl;
     47import org.hibernate.tool.schema.internal.ExceptionHandlerHaltImpl;
     48import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
     49import org.hibernate.tool.schema.internal.IndividuallySchemaMigratorImpl;
     50import org.hibernate.tool.schema.spi.ExceptionHandler;
     51import org.hibernate.tool.schema.spi.ExecutionOptions;
    4952import org.hibernate.tool.schema.spi.SchemaCreator;
    5053import org.hibernate.tool.schema.spi.SchemaMigrator;
    51 import org.hibernate.tool.schema.spi.Target;;
     54import org.hibernate.tool.schema.spi.ScriptSourceInput;
     55import org.hibernate.tool.schema.spi.ScriptTargetOutput;
     56import org.hibernate.tool.schema.spi.SourceDescriptor;
     57import org.hibernate.tool.schema.spi.TargetDescriptor;
    5258
    5359/**
     
    119125      final CollectSqlTarget indexUpdates = new CollectSqlTarget();
    120126     
     127      ServiceRegistry serviceRegistry = ((MetadataImplementor)metadata).getMetadataBuildingOptions().getServiceRegistry();
     128      HibernateSchemaManagementTool tool = new HibernateSchemaManagementTool();
     129      tool.injectServices((ServiceRegistryImplementor)serviceRegistry);
     130     
    121131      if (mode == Mode.UPDATE)
    122132      {
    123133        log.info("Fetching database metadata");
     134        /*
    124135        ServiceRegistry serviceRegistry = ((MetadataImplementor)metadata).getMetadataBuildingOptions().getServiceRegistry();
    125136        JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
     
    128139        Namespace ns = metadata.getDatabase().getDefaultNamespace();
    129140        DatabaseInformation existingDatabase = new DatabaseInformationImpl(serviceRegistry, jdbcEnvironment, jdbcConnectionAccess, ns.getPhysicalName().getCatalog(), ns.getPhysicalName().getSchema());
     141        */
    130142       
    131143        log.info("Generating schema update script");
    132         SchemaMigrator schemaMigrator = new SchemaMigratorImpl();
    133         schemaMigrator.doMigration(metadata, existingDatabase, false, Arrays.asList((Target)schemaUpdates));
     144        SchemaMigrator schemaMigrator = new IndividuallySchemaMigratorImpl(tool, null);
     145        schemaMigrator.doMigration(metadata, schemaUpdates, schemaUpdates);
    134146      }
    135147      else if (mode == Mode.INSTALL)
    136148      {
    137149        log.info("Generating schema creation script");
    138         SchemaCreator schemaCreator = new SchemaCreatorImpl();
    139         schemaCreator.doCreation(metadata, false, schemaUpdates);
     150        SchemaCreator schemaCreator = new SchemaCreatorImpl(tool);
     151        schemaCreator.doCreation(metadata, schemaUpdates, schemaUpdates, schemaUpdates);
    140152      }
    141153      else
     
    228240  */
    229241  static class CollectSqlTarget
    230     implements Target
     242    implements ScriptTargetOutput, SourceDescriptor, TargetDescriptor, ExecutionOptions
    231243  {
    232244    private final List<SqlStatement> allSql;
     
    269281   
    270282    @Override
    271     public boolean acceptsImportScriptActions()
    272     {
    273       return false;
    274     }
    275    
    276     @Override
    277283    public void accept(String sql)
    278284    {
     
    281287      if (modifiedSql != null) numStatements++;
    282288    }
     289
     290    @Override
     291    public ScriptSourceInput getScriptSourceInput()
     292    {
     293      return null;
     294    }
     295
     296    @Override
     297    public SourceType getSourceType()
     298    {
     299      return SourceType.METADATA;
     300    }
     301   
     302    @Override
     303    public EnumSet<TargetType> getTargetTypes()
     304    {
     305      return EnumSet.of(TargetType.SCRIPT);
     306    }
     307
     308    @Override
     309    public ScriptTargetOutput getScriptTargetOutput()
     310    {
     311      return this;
     312    }
     313
     314    @Override
     315    public Map<?, ?> getConfigurationValues()
     316    {
     317      return Collections.emptyMap();
     318    }
     319
     320    @Override
     321    public boolean shouldManageNamespaces()
     322    {
     323      return false;
     324    }
     325
     326    @Override
     327    public ExceptionHandler getExceptionHandler()
     328    {
     329      return ExceptionHandlerHaltImpl.INSTANCE;
     330    }
     331   
     332   
    283333  }
    284334 
Note: See TracChangeset for help on using the changeset viewer.