Hi!

I am trying to create a startup service that will initialize a database for me. 
 I'm on Tapestry 5.3.1 and I am using tapestry-hibernate.

All the evidence I've been able to find suggests that @CommitAfter isn't 
executing a commit.  Transactions in components that write to the DB after 
initialization work fine (using @CommitAfter).  I can see from the logs that 
the 'flush' for the transaction in question works correctly (but apparently no 
commit, which I know because the record is not in the DB afterwards).

Any suggestions as to what I'm missing?

Thanks!!!
Jochen

PS: I tried setting up my own transaction, but that fails miserably with an 
Exception (Transaction trx = session.beginTransaction();...  trx.commit();)

================== Code which isn't committing 
(DevelopmentDBStartupServiceImp.java) ========

    public DevelopmentDBStartupServiceImpl(Logger logger, Session session,
                                           
@Symbol(SymbolConstants.PRODUCTION_MODE) boolean isProductionMode) {
        this.logger = logger;
        this.session = session;
        this.isProductionMode = isProductionMode;
    }

--- SNIP ---

    @CommitAfter
    private boolean initSchemaVersion ()
    {

        // ---- SNIP ----

        // we'll assume that it's a virgin DB
        SchemaVersion version = new SchemaVersion(SchemaVersion.MAJOR_VERSION, 
SchemaVersion.MINOR_VERSION);
        session.save(version);
        session.flush();
        return true;
    }

=========== How it's called (excerpts from DevelopmentModule.java) =========

    public static void bind(ServiceBinder binder)
    {
        binder.bind(DevelopmentDBStartupService.class, 
DevelopmentDBStartupServiceImpl.class);
    }

    @Match("*DB*")
    public static void adviseTransactions(HibernateTransactionAdvisor advisor, 
MethodAdviceReceiver receiver)
    {
        advisor.addTransactionCommitAdvice(receiver);
    }

    @Startup
    public static void initDevelopmentDatabase (Logger logger, 
DevelopmentDBStartupService service)
    {
        logger.info("START Initializing development database.");
        service.init();
        logger.info("DONE initializing development database.");
    }




---
  Jochen Frey
  joc...@beckon.com
  +1.415.366.0450
  @jochen_frey






---
  joc...@jochenfrey.com
  +1.415.366.0450
  @jochen_frey


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to