[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - newbie: import script questions
mars1412
do-not-reply at jboss.com
Thu Feb 21 08:46:02 EST 2008
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)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131069#4131069
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131069
More information about the jboss-user
mailing list