These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: multiple concurrent transactions from same session
PostPosted: Wed Nov 10, 2004 4:17 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
Hi,
Can multiple concurrent transactions be opened from same session, and
(2) how does one achieve the equivalient of java.sql.Statement.addBatch and
executeBatch in hibernate?

thank you.

| eg |


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 10, 2004 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
(1) Not possible and would be very wrong (2) Hibernate automatically uses JDBC batch operations if possible.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 2:45 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
If i'm expecting my use case to be frequent small reads and very few writes by different threads (use of threadlocal pattern is not possible, rmi), how often should i open/close session, or would it make sense to have a session pool, with session's being cleared and every checkin/checkout?

thank you,

|eg|


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 4:04 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Command must be a good way for this use case :

abstract class Command {


protected abstract Serializable doExecute(Serializable[] args);

final public Serializable execute(Serializable[] args){
Session s = getSession();
try{

Serializable result = doExecute(args);
//commit
return result;
}finally{
s.close();
}


}


}
Remote object implementation is trivial:

Serializable execute( Serializable cmdId, Serializable[] args)
throws RemoteExeption{

return COMMAND_MAP.getCommand(cmdId).execute(args)

}


Client can send command id or it can use dynamic Proxy to convert method to command id before to invoke remote method.

I never use RMI in practice, but I experimented on j2ee container and it looks like there are no problems with this command suff. The nice thing about commands is reusability, it can be reused with any protocol or messaging (single line adapter) and it reduces code duplication.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 4:53 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
This is very similiar to what i have now. I just wasn't sure that session-per-request was the way to go, mostly because i don't know what the overhead is for opening/closing a session.

thank you for your response.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 5:07 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You can think about session as wrapper for JDBC connection or client socket, it must be trivial to understand things by this analogy.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.