0 Replies Latest reply on Feb 21, 2008 8:45 AM by mars1412

    newbie: import script questions

    mars1412 Apprentice

      1) what character encoding do I need to use for the import.sql file: ISO-8859-1 or UTF-8

      2) when you have master-child data to insert, what is the best way to do it?
      since I am using MS-SQL database, the ID's will be generated by the database, so I must do this:

      insert into ParentTable (field1, field2, ..) values (..)
      insert into Child Table (filed1, field2, .., ParentId) values (..., 1)
      insert into Child Table (filed1, field2, .., ParentId) values (..., 1)
      insert into ParentTable (field1, field2, ..) values (..)
      insert into Child Table (filed1, field2, .., ParentId) values (..., 2)


      • this is not really nice, that I have to "guess" the parent id
      • the other thing is, that when you ever change your database to e.g. oracle, you have to completely rewrite your importscript: e.g. in this case, you have to add the id field for every row
        insert into ParentTable (id, field1, field2, ..) values (1, ..)
        insert into Child Table (id, filed1, field2, .., ParentId) values (1, ..., 1)
        insert into Child Table (id, filed1, field2, .., ParentId) values (2, ..., 1)
        is there a better way?
        maybe I should not use the updatescript at all and create the data on application startup in java-code - then I could insert my entities and didn't have to care about the underlying database, right?

        3) is this right:
        the import.sql not really has anything todo with hibernate - it's just an importscript and hibernate automatically executes it against your database at startup (if configured)