-
Notifications
You must be signed in to change notification settings - Fork 934
NH-3675 - Support Bulk Inserts #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
{ | ||
foreach (var entity in entities) | ||
{ | ||
if (session is ISession) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why is that? Another option is to return null, that is, not have a default bulk provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it uses "is-as" checks. A preffereble way is to use "as" and compare to null. Mainly because "is" and "as" are compiled to the same IL opcode "isinst".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is totally irrelevant. But I changed this method to always use stateless session, don't want to store these entities in the first level cache
Hi @rjperes, thanks for the great work. But can you please utilize |
Can't use IEntityPersister.GetPropertyValuesToInsert because it returns an array of objects, containing possibly complex classes, in the case of components, many-to-one or one-to-one associations. |
2014-10-29 21:15 GMT+13:00 Ricardo Peres [email protected]:
We eitther need (1)to teach IType to set values to a DataTable, instead of |
var persister = session.GetEntityPersister(entityType.FullName, null) as AbstractEntityPersister; | ||
var table = new DataTable(); | ||
|
||
if (persister is SingleTableEntityPersister) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following if-then-else can be replaced with only one
var abstractEntityPersister = persister as AbstractEntityPersister;
if (abstractEntityPersister != null) {
table.TableName = abstractEntityPersister .TableName;
}
Because SingleTableEntityPersister, JoinedSubclassEntityPersister, and UnionSubclassEntityPersister inherit AbstractEntityPersister and TableName is it's property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, persister is already AbstractEntityPersister
, so just persister.TableName;
Added DefaultBulkProvider class as the default
Removed dependency of System.Web and DataBinder.Eval Using ADOExceptionHelper.Convert to convert DB exceptions BulkInsert only applies to IStatelessSession Small improvements
Hello, I stumbled over this pull request today and would appreciate if this feature would be accepted. We've also integrated a bulk implementation for MSSQL done in the same way in our product and I would consider to replace it by native NHibernate functionality in this case. However, I got some issues:
|
The PR opener having deleted his nhibernate repository, it seems likely to me this PR will not move forward unless someone re-issue it and work on it. For how to do that with a deleted repository, one way is to do like here. |
What a pity. |
https://nhibernate.jira.com/browse/NH-3675
Initial implementation with unit tests