Hi,

I have two services, namely MyCreate and MyThread, what they do is:

MyCreate will append a new record using Tapestry-Hibernate's session and
MyThread will look it up, MyThread is in a thread while MyCreate is not, the
problem is, the newly created record can not be located by MyThread, if
MyThread is called as non-threaded service, everything works.

Also if the table type is MyISAM, the threaded service works too, it only
comes out when the type is InnoDB, any ideas? here is the code:


// page

  @Inject
  private MyCreate create;
  @Inject
  private MyThread myThread;

  Object onSuccess() {
        final Long id = create.append();
        new Thread(new Runnable() {
          public void run() {
            myThread.findMe(id);
          }
      }).start();
      return null;
  }

// services

public class MyCreateImpl implements MyCreate {

    final private Session session;
    public MyCreateImpl(Session session) { this.session = session;}

    public Long append() {
        Usr usr = new Usr();
        usr.setName("test");
        session.save(usr);
        return usr.getId();
    }
}

public class MyThreadImpl implements MyThread {

    final private Session session;
    final private ThreadCleanupHub threadCleanupHub;

    public MyThreadImpl(Session session, ThreadCleanupHub threadCleanupHub)
{
        this.session = session;
        this.threadCleanupHub = threadCleanupHub;
    }

    public void findMe(Long id) {
        System.out.println(id);
        Usr u = (Usr) session.get(Usr.class, id);
        if (u != null)
            System.out.println("found " + u.getName());
        else
            System.out.println("not found2");
        threadCleanupHub.cleanup();      
    }
}
-- 
View this message in context: 
http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15328171.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to