How to model/map files (with their content) e.g. in webapplications?
What is the best practice?
(1) To put their content as blob fully in the DB plus fields for
properties,
or
(2) to put the metadata about files only in the DB and the content
in a file system?
or
(3) other solution?
The second one seems to be the most efficient, but than the entire
transaction
support is lost :(.
Cayenne itself doesn't care too much either way. I suspect your decision
will come to things outside Cayenne such as:
Well, I hoped Cayenne has some solution for such a common problem, e.g.
to allow
to handle those "files" as simple persistent entities (something similar
to extend types), like all the other entities (since they are in
relationship) :).
* do you wish to end up with these blobs in memory or can you avoid that
by streaming directly from disk
Of course: as less memory as possible :).
(eg. through Apache httpd without
touching Java)
I need a pure Java solution, no httpd, ajp connectors etc. :(.
* how will your database cope?
* how will your database backup processes cope?
Ideally I wouldn't care much about the database (that's why I'm trying
to adopt an ORM as a layer over it :) ).
E.g. This https://issues.apache.org/jira/browse/CAY-155
would allow to care less about the DB :).
Also, an ANT task similar to Cayenne
http://cayenne.apache.org/doc/cdataport.html but to hide this entire
backup/restore mess, would be ideal e.g. "cbackup/crestore" :).
* how will you manage the files on the file system? Will people touch
them without going through your code and therefore break the links
between the metadata and the files?
Most webapplations are on some remote server, so users can access them
only with the web UI. Unfortunately this is not as good as if they're
part of the Cayenne DataContext transaction.
Thank you,
Joseph.