{"action":"opened","issue":{"url":"https://api.github.com/repos/Particular/NServiceBus.NHibernate/issues/99","labels_url":"https://api.github.com/repos/Particular/NServiceBus.NHibernate/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/Particular/NServiceBus.NHibernate/issues/99/comments","events_url":"https://api.github.com/repos/Particular/NServiceBus.NHibernate/issues/99/events","html_url":"https://github.com/Particular/NServiceBus.NHibernate/issues/99","id":74301365,"number":99,"title":"When storing a timeout entity NH cannot determine wether it should call `Save` or `Update`","user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Particular/NServiceBus.NHibernate/labels/Improvement","name":"Improvement","color":"22BB88"}],"state":"open","locked":false,"assignee":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-05-08T09:32:36Z","updated_at":"2015-05-08T09:32:36Z","closed_at":null,"body":"### Symptoms\r\n\r\nWhen storing timeouts with the NHibernate persistence the following warning is raised:\r\n\r\n> 2015-05-08 09:28:40,547 [45] WARN NHibernate.Engine.ForeignKeys [(null)] <(null)> - Unable to determine if NServiceBus.TimeoutPersisters.NHibernate.TimeoutEntity with assigned identifier 79ddf583-fccc-4814-a1dc-a492009c3105 is transient or detached; querying the database. Use explicit Save() or Update() in session to prevent this.\r\n\r\n### Who's affected\r\n\r\nEveryone using NHibernate persistence to store timeouts.\r\n\r\n### Analysis \r\nWhen we store a `TimeoutEntity` we are always assigning a new CombGuid. Then we save the newly created `TimeoutEntity` with `session.SaveOrUpdate`. This has a performance hit. NHibernate cannot figure out by looking at the entity whether it is a new or an already existing entity and needs to issue a select query to determine whether it should generate an insert or an update statement. But in the case of storing timeouts we should always do an insert. "}}