First I have a source class like this.
public class Source
{
        Transaction tx;

        List pendingRemovedItems;
        public void beginTransaction()
        {
                // here I use ThreadLocal pattern.
                tx= ThreadState.getSession().beginTransaction();
        }

        public void commit()
        {
                try
                {
                        // I need to explicitly delete all items that need
deletion.
                        for (Iterator iter= pendingRemovedItems.iterator();
                                iter.hasNext();
                                )
                        {
                                ThreadState.getSession().delete(iter.next());
                        }

                        tx.commit();
                        logger.info(" db source is commited");
                        pendingRemovedItems.clear();
                } finally
                {
                        tx= null;
                }
        }
        
        // other variables and methods in source.
}


My application code is like this
Source src=...;
// when control comes here, there are about 500
persistence objects in session.
1. src.beginTransaction();
2. // here an new transient object is persisted.
3. src.commit();

The code fragment 1, 2, and 3 will be run 300 to 500
times. 


The following is sql code dumped from hibernate. That
is exactly what I expected. I only show 2 of them. The
timestamp indicated that each insertion was about one
second.

I am happy to provide any extra information.


2003-9-12 12:31:02 ....
Info: found cached source
Hibernate: select seq_resourceID.nextval from dual
Hibernate: insert into contact (luid, dbId, guid,
namefirst, namelast, nameother, nameprefix,
namesuffix, title, role, orgname, orgunit, birthday,
url, nickname, timezone, note, binary, categories,
class, contactID) values (?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'd', ?)
Hibernate: insert into phonenumber (contactID, num,
type) values (?, ?, ?)
Hibernate: insert into email (contactID, email, type)
values (?, ?, ?)
2003-9-12 12:31:03 ...
Info:  db source is commited
2003-9-12 12:31:03 ....

2003-9-12 12:31:03 ...
Info: found cached source
Hibernate: select seq_resourceID.nextval from dual
Hibernate: insert into contact (luid, dbId, guid,
namefirst, namelast, nameother, nameprefix,
namesuffix, title, role, orgname, orgunit, birthday,
url, nickname, timezone, note, binary, categories,
class, contactID) values (?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'd', ?)
Hibernate: insert into email (contactID, email, type)
values (?, ?, ?)
Hibernate: insert into phonenumber (contactID, num,
type) values (?, ?, ?)
2003-9-12 12:31:04 ...
Info:  db source is commited


--- Gavin King <[EMAIL PROTECTED]> wrote:
> 
> >the transaction. My code is like this
> >
> >Tranaction tx=sessiob.beginTransaction();
> >foo.setField(newValue);
> >tx.commit();
> >
> 
> Well, obviously it is not like that, since that code
> does not
> load any objects into the session.
> 
> >1. When the commit() is called, will the hibernate
> >loop through every object in the session
> >and check for modification?
> >
> Yes.
> 
> >2. If it does, is it an expensive operation?
> >
> 
> No, not at all.
> 
> >Any suggestion to solve the performance bottleneck
> in
> >my situation is really appreacited.
> >
> 
> Exactly what does your code *really* look like?
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to