<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Web application and multiple sessions"]]></title>
		<link>http://forums.visual-paradigm.com/posts/32.html</link>
		<description><![CDATA[Latest messages posted in the topic "Web application and multiple sessions"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Web application and multiple sessions</title>
				<description><![CDATA[ I am working on a web application that runs under Visual Studio 2005, language C#. I designed with Visual Paradigm the classes diagram and automatically generated the database and code with the VP tools.<br> <br> The Perstent API type I used for code generation is "Static Methods", I think is the most simple and ok for me.<br> <br> I created a class called dao.cs so it contains every access to the database and connections. It looks like this:<br> <br> public class dao<br> {<br> 	private PersistentManager persistenceManager = HMIPersistentManager.Instance();<br> <br> 	private static dao instance = null;<br> <br> 	private dao()<br> 	{<br> 	}<br> <br> 	public static dao getInstance()<br> 	{<br> 		if (instance == null)<br> 			instance = new dao();<br> 		return instance;<br> 	}<br> <br>          public Recipe getRecipeByID(int id)<br> 	{<br> 		PersistentTransaction t = this.persistenceManager.GetSession().BeginTransaction();<br> <br> 		Recipe a = Recipe.LoadRecipeByORMID(id);<br> <br> 		t.Commit(); // <<-- exception here: already opened conexion or ID already in use....<br> 		return a;<br> 	}<br> <br>         /* more methods... */<br> <br>  <br> }<br> <br> The problem is, when executing the project, sometimes it throws an exception on the "t.Commit();" line. I would like to implement the best way for a web application: multiple users accessing the database, and everything running fine.<br> <br> Do I need to use a lock like:<br> PersistentManager.instance().getSession().lock(obj, LockMode.NONE);<br> <br> Where do I put it? Which lockmode choose?<br> <br> Thanks in advance]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2739#20472.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2739#20472.html</link>
				<pubDate><![CDATA[Wed, 19 Dec 2007 19:31:16]]></pubDate>
				<author><![CDATA[ hectoret]]></author>
			</item>
			<item>
				<title>Web application and multiple sessions</title>
				<description><![CDATA[ Hi hectoret,<br> <br> When running in web environment, please make sure have<br> <br> 1. close session before return values<br> <br> 2. running thread based session  <br> <br> XXPersistentManager.SetSessionType(PersistentManager.SessionType.THREAD_BASE);<br> <br> Hope this helps.<br> <br> Best regards,<br> Rain<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2739#20491.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2739#20491.html</link>
				<pubDate><![CDATA[Fri, 21 Dec 2007 18:26:26]]></pubDate>
				<author><![CDATA[ Rain]]></author>
			</item>
	</channel>
</rss>