A
aDeamon
Hi,
I am a (new) Hibernate 3.2 user and trying out diffrent things.
For example I have managed to setup an application that inserts,
retrives, and delete objects in a database. I have also instructed
hibernate to update the set of tables when ever it restarts (with
hibernate.hbm2ddl.auto=update)
But what I am instructed to do is also to create a new table after
that the application has started. Probably not a good idea cause you
cant do the "fancy" Hibernate things on this new table. But
instructions are instructions, right...
Now this is not so hard to do when you use plain SQL statements such
as
CREATE TABLE table_name (id biginteger, name varchar(50))
When I use this as String query in the following
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
session.createQuery(query);
I get an error
unexpected token: create
Probably because create isn't allowed. My question then - is there
someway to create a new table with Hibernate after application started?
I am a (new) Hibernate 3.2 user and trying out diffrent things.
For example I have managed to setup an application that inserts,
retrives, and delete objects in a database. I have also instructed
hibernate to update the set of tables when ever it restarts (with
hibernate.hbm2ddl.auto=update)
But what I am instructed to do is also to create a new table after
that the application has started. Probably not a good idea cause you
cant do the "fancy" Hibernate things on this new table. But
instructions are instructions, right...
Now this is not so hard to do when you use plain SQL statements such
as
CREATE TABLE table_name (id biginteger, name varchar(50))
When I use this as String query in the following
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
session.createQuery(query);
I get an error
unexpected token: create
Probably because create isn't allowed. My question then - is there
someway to create a new table with Hibernate after application started?