-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: migration from 3.3 to 5.1, SchemaUpdate issue
PostPosted: Tue Apr 26, 2016 9:39 am 
Newbie

Joined: Tue Apr 26, 2016 5:28 am
Posts: 2
Hi,

I am currently trying to migrate our old code from hibernate 3.3 to the last version.

This seems to work, however for now I had to removed calls to SchemaUpdate:
Code:
   Configuration cfg = new Configuration();
   /* here goes lot of driver,property and resource setup */
   [...]
   sessionFactory = cfg.buildSessionFactory();

   SchemaUpdate update = new SchemaUpdate( cfg );
   update.execute( false, true ); /* this line do not compile anymore with hibernate 5.1 */


So my question is: what is the exact replacement of update.execute ? (I have no idea what this code is supposed to do)

Documentation pointing to a execute with different parameter, where am i supposed to get them ?
Should I rewrite the whole bootstrapping process with the new API ?


Top
 Profile  
 
 Post subject: Re: migration from 3.3 to 5.1, SchemaUpdate issue
PostPosted: Tue Apr 26, 2016 11:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
The bootstrap has changed significantly. Check out the Bootstrap section on the 5.1 docs.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: migration from 3.3 to 5.1, SchemaUpdate issue
PostPosted: Wed Apr 27, 2016 3:54 am 
Newbie

Joined: Tue Apr 26, 2016 5:28 am
Posts: 2
mihalcea_vlad wrote:
The bootstrap has changed significantly. Check out the Bootstrap section on the 5.1 docs.


I did read that section of the documentation but there is not a single word in SchemaUpdate. Also it far to be clear what is the exact equivalent of the previous setup process.


Top
 Profile  
 
 Post subject: Re: migration from 3.3 to 5.1, SchemaUpdate issue
PostPosted: Wed Apr 27, 2016 5:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
Right. There you go. This is a snippet from a Hibernate test:

Code:
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
        .applySetting( Environment.HBM2DDL_AUTO, "none" )
        .build();
try {
    File output = File.createTempFile( "update_script", ".sql" );
    output.deleteOnExit();

    final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr )
            .addResource( "org/hibernate/test/schemaupdate/inheritance/Payment.hbm.xml" )
            .buildMetadata();
    metadata.validate();

    new SchemaUpdate()
            .setHaltOnError( true )
            .setOutputFile( output.getAbsolutePath() )
            .setDelimiter( ";" )
            .setFormat( true )
            .execute( EnumSet.of( TargetType.SCRIPT ), metadata );

    String fileContent = new String( Files.readAllBytes( output.toPath() ) );
    assertThat( fileContent.toLowerCase().contains( "fk_cc_pay" ), is( true ) );
}
finally {
    StandardServiceRegistryBuilder.destroy( ssr );
}

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.