simonwillnauer wrote:
Listerner listening for a delete action of a image.
The link you posted looked very promising!
simonwillnauer wrote:
but if you use a "cascade" I guess you need to build your listener into hibernate.
Why? Listeners aren't notified if the object is deleted by cascading?
simonwillnauer wrote:
For ex. if you use a dao-pattern you might have a ImageDAO with a method
"public void removeImage(Long id) throws DAOException".
If you use a DomainModel you might have your action methodes in your Entity and you use a cascade="delete"
So it depends on your model.
I'm not quite sure what model I use. I use NHibernate, the access to it is encapsulated in a class DataAccess, which again is encapsulated in another class. Clients don't see the DataAccess class, they call the encapsulating service class instead.
The service class uses interfaces, DataAccess uses implementing classes.
simonwillnauer wrote:
So in MSSql you can put freign key constraint on the references to you images. Just an additional security...
Do you happen to know how?
simonwillnauer wrote:
I don't know what you are doing with your images but you can build many-to-man relations to the pictures but you have to figure out if there any references to it before you remove it from your filesystem.
I won't need many-to-many, it's usually one-to-one (one object, one image), many-to-one (several objects reference one image). The latter is very unlikely to happen.
simonwillnauer wrote:
Whats about saving your image right in the database? Is that worth considering?
This is commonly discouraged. Also I don't want to change all my code now.