Not all databases handle DDL the same in
terms of transactional semantics.
The simple (and most natural) solution is
to bootstrap your SessionFactory (and thus run hbm2ddl) when the app
deploys/starts-up, not on first access.
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jan Janecek
Sent: Friday, January 13, 2006
10:10 AM
To:
hibernate-devel@lists.sourceforge.net
Subject: [Hibernate] Commit when
updating db schema in hbm2ddl
Hi,
commit issued by hbm2ddl when updating database schema is fairly problematic.
It failes when hbm2ddl is run in container managed bean.
I have a framework that fairly well converts project in ejb3 to ejb2.1. Problem
arises with injection of EntityManager. I implement this injection by an
aspect. This aspect is invoked every time the field annotated with
@javax.persistence.PersistenceContext is read. If it is read for the first time
inside a CMP bean then hbm2ddl is run (and I want to have it run) but fails
because of the mentioned commit statement.
Is there a simple workaround (except for the obvious one - get the
EntityManager inside a BMP bean for the first time)?
Is issuing commit realy necessary at all? I've thought that ddl commands don't
run in a transaction.
Thanks for help,
Jan
PS: I'm sorry if this e-mail is inappropriate in this list but I've seen the
same problem posted to the users list with no reply.
|