Hi all,
I have run into problems trying to implement a file upload application with hibernate. I think it is a matter of trying to design the right way rather than a technical issue. My problem is:
I have a table called contract which has 1:M relationship with another table called contract_file. A contract can have many contract_files. Now the problem is when I create a contract, as part of the process I'm uploading one or many contract_files. Because contract_files can take quite a lot of memory I'm trying to persist them into their respective tables rather than hold it in the memory until the contract itself is saved. But I encountered the following problem:
1. The contract_files table has a foreign key field pointing to contract id which is null at the time of saving the contract file because the contract itself is not saved.
All I want to do is upload the files and save them directly to the database first, then when the contract is being saved attach the relevant files to it and if the contract is not saved delete these files. Has someone done this before? How can I design the tables in such a way without having the files in the memory? Also how to configure Hibernate files?
Please advice me of any techniques I can use to implement this application.
|