Visual Paradigm Logo
     Build Quality Applications Faster, Better and Cheaper
 
Home | Products | Download | Documentation | Support | Resources | Partners | Quick Tour | Shop | Company |  
 
   Visual Paradigm Discussion Forum
  Login   [ Register ] Email: Password: Log me on automatically I lost my password  
Recent Topics
Advanced Search
Web application and multiple sessions  
Forum Index -> DB Visual ARCHITECT (DB-VA)
Author Message
hectoret


Joined: 2007/12/19
Messages: 1

Offline

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.

The Perstent API type I used for code generation is "Static Methods", I think is the most simple and ok for me.

I created a class called dao.cs so it contains every access to the database and connections. It looks like this:

public class dao
{
private PersistentManager persistenceManager = HMIPersistentManager.Instance();

private static dao instance = null;

private dao()
{
}

public static dao getInstance()
{
if (instance == null)
instance = new dao();
return instance;
}

public Recipe getRecipeByID(int id)
{
PersistentTransaction t = this.persistenceManager.GetSession().BeginTransaction();

Recipe a = Recipe.LoadRecipeByORMID(id);

t.Commit(); // <<-- exception here: already opened conexion or ID already in use....
return a;
}

/* more methods... */


}

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.

Do I need to use a lock like:
PersistentManager.instance().getSession().lock(obj, LockMode.NONE);

Where do I put it? Which lockmode choose?

Thanks in advance
 
Rain


Joined: 2005/04/29
Messages: 735

Offline

Hi hectoret,

When running in web environment, please make sure have

1. close session before return values

2. running thread based session

XXPersistentManager.SetSessionType(PersistentManager.SessionType.THREAD_BASE);

Hope this helps.

Best regards,
Rain
 
 
   Forum Index -> DB Visual ARCHITECT (DB-VA)
Go to:   
Powered by JForum 2.1.4 © 2005 - Rafael Steil