I'm having trouble with saving an object into my database using NHibernate.
My code looks like this:
Image image = new Image { Url = 'test.jpg' };
Product product1 = new Product { Name = 'MyProduct', Image = image };
Product product2 = new Product { Name = 'MyProduct2', Image = image };
MySession.Save(product1); // This also creates an Image record
MySession.Save(product2); // This creates another Image record even tho the data is exactly the same
I would like to prevent the image from being created twice. Is there a standard NHibernate solution for that or do i have to create a custom Save() method for the Product class?