2012/8/9 mukesh Chandra <[email protected]>
> I have three database tables create in SQLLite
>
> Receipt, receiptUDF and ReceiptIndexes
> Receipt can have zero or more entries for ReceiptUDFs and Receipt Indexes
> in it.
>
>
> <list name="indexFields" cascade="all-delete-orphan">
>
Be aware that the <list> will persist and preserve ordering. If you remove
the first element, or insert an element in the middle, NHibernate needs to
update the index for all elements in the collection. A lot of extra work if
the number of elements is high unless you really need to preserve the
ordering.
> Problem:
> ____________
>
> When I try to save or update the Receipt object It is taking a lot of
> time. I have experienced that the time taken to add/update a receip
> increases as we have more Receipts in the database.
>
How long does is take, and what time do you think would be reasonable?
Gradually longer times could mean that you need better indexing in the
database, or that you are gradually accumulating objects in your NHibernate
session.
> I looked at the hibernate log files and foind following logs
>
>
>
> Following is the code I am using to Save
>
> /// <summary>
> /// Save a Receipt
> /// </summary>
> /// <param name="receipt"></param>
> public void Add(Receipt receipt)
> {
> using (ITransaction transaction = _session.BeginTransaction())
> {
>
> _session.Save(receipt);
> try
> {
> // _session.Persist(receipt);
> transaction.Commit();
>
This will perform a dirty check of all objects and flush of all changes
found in the NHibernate session. Probably you should not mess about with
transactions in this part of the code.
> }
> catch (ADOException e)
> {
> Console.WriteLine(e.ToString());
>
Exception hiding is an anti-pattern.
> }
> }
> }
>
> /// <summary>
> /// Update a Receipt
> /// </summary>
> /// <param name="receipt"></param>
> public void Update(Receipt receipt)
> {
> using (ITransaction transaction = _session.BeginTransaction())
> {
> _session.Update(receipt);
>
This is only required and useful if the session is currently unaware of the
receipt object. Otherwise it is already tracked by the session.
/Oskar
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.