ObjectDB ObjectDB

use of Singleton into tomcat


hi all.

i would write a class singleton that encapsulate the entitymanagerFACTORY    into it.(the entitymanagerFactory  IS A property of the only instance of class singleton. (the class singleton is not a Ejb!!!!!!!!!).

into tomcat it not possible  use ejbs.............

i have to manage the concurrency for the operations on db...............

with a method static i can get the only instance of singleton for manage all operation on database.

I get a instance of it into multiple servlet.

but into the class singleton i would write a set of method for the operation for example with serarch for name of a user, a search for a lastname, so way.

but i ask if all method it to be syncorniuzed into signature??????

for example:

public syncronized User searchForName(String name){

User user=null

//query for get the user correspondant.

return user;


public void  syncronized updateUser(User userToUpdater){

//code for update into db }


but i ask if the metods for update, write . read , create Users it to be syncornized into signature or with the word syncornized form the body of the metods????


getr me please.........

i know that the servlet it multi.tread ad so the operation on db  it not thread-safe.

but  how it work the methods into singleton for read, update, write at db if 2 client it call the methods on mode concurrent?????

write me a example .

i wait for a response.

tank you







This is a Java question rather than an ObjectDB question.

You may wish to post it on a Java forum or on StackOverflow.

ObjectDB Support


To post on this website please sign in.