-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: File upload help
PostPosted: Tue Nov 03, 2009 12:01 pm 
Newbie

Joined: Fri Oct 30, 2009 9:13 am
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: File upload help
PostPosted: Tue Nov 03, 2009 4:34 pm 
Newbie

Joined: Fri Apr 03, 2009 4:12 pm
Posts: 9
Try to allow null values in the column with the foreign key.

Then save the contract file with a null contract (contractFile.setContract(null)) and update it when the contract has been saved.

_________________
Santiago GarcĂ­a Pimentel R.G.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.