Custom NHibernate entity persister for modifying generated SQL statements
What I need is to populate entity from DB view (non-insertable) and make all entity updates to updatable DB table.
- Mapping entity to table and writing custom load SQL from view is not an option since in some cases NHibernate still tries to select from table name (when joining this entity, for example).
- Mapping entity to view and writing custom data modification queries is not an option since I can not write cross-database sql-insert statement (because of the last inserted identity value selection part).
The only idea I came up with for now is to modify generated SQL statements on-the-fly. I managed to do it with custom interceptor but I don't think that its a good idea (since I intercept every single query, even for other entities). However, I think that it should be possible to change only needed queries using custom IEntityPersister
. I created one based on SingleTableEntityPersister
, specified it in <class persister="…">
, but NHiber开发者_开发问答nate doesn't even want to instantiate it.
Are there any examples of writing custom entity persisters for NHibernate?
精彩评论