Announcement Announcement Module
No announcement yet.
create-drop not working, probably a bug in hibernate Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • create-drop not working, probably a bug in hibernate

    I'm posting this to figure out if this is a bug in hibernate or if I am doing something wrong. I have a really simple data access setup and trying to unit test a simple create of my object.

    But i get an exception when running my unit test saying the table for my entity is missing. My hibernate configuration for my sessionfactory states create-drop. (Before you ask, yes i'm sure this setting is used in my unit test correctly).

    So i starting debugging into the hibernate source code. (version 3.5.6-Final)

    In SessionFactoryImpl in the init method there is following code:

    		if ( settings.isAutoCreateSchema() ) {
    			new SchemaExport( cfg, settings ).create( false, true );
    		if ( settings.isAutoUpdateSchema() ) {
    			new SchemaUpdate( cfg, settings ).execute( false, true );
    		if ( settings.isAutoValidateSchema() ) {
    			new SchemaValidator( cfg, settings ).validate();
    		if ( settings.isAutoDropSchema() ) {
    			schemaExport = new SchemaExport( cfg, settings );
    In the SchemaExport class you have the execute method:

    Code: "Running hbm2ddl schema export" );
    		Connection connection = null;
    		Writer outputFileWriter = null;
    		Reader importFileReader = null;
    		Statement statement = null;
    		try {
    			try {
    				InputStream stream = ConfigHelper.getResourceAsStream( importFile );
    				importFileReader = new InputStreamReader( stream );
    			catch ( HibernateException e ) {
    				log.debug( "import file not found: " + importFile );
    			if ( outputFile != null ) { "writing generated schema to file: " + outputFile );
    				outputFileWriter = new FileWriter( outputFile );
    Now I'm getting somewhere because i get the import file not found (shouldn't this be an error instead of a debug message????)

    Anyone who has an idea what is causing this file not found?
    I don't expect that I shall create this as I choose for hibernate to create my database schema automatically using create-drop.