Hibernate version: 3.x
I have two tables. First with Users, second with Category.
For example
Code:
User
id | name | categoryId
----------------------------
1 | Paul | 3
2 | Raul | 2
4 | Alice | 5
Category
id | name
----------------------------
2 | one
3 | two
5 | three
I want to transfer database from one server to another. In program i use serialization to do this. I read all object and save (serialize) it to file. I copy this file to another server. Database is save as object into the file. In second server i just read it, and one more time save.
The problem is - how to save object with custom id. When i read object from file - they have right id. After i save it - they have auto generate id from hibernate. Foreign key categoryId - isn't right. Category have another new id.
The best solution is - save object with right, custom id. How to do this ?
thanks for help!