> CREATE TABLE table_name (id biginteger, name varchar(50))
>
[quoted text clipped - 7 lines]
>
> unexpected token: create
The reason you get "unexpected token" is because you feed it an SQL
query, but the method createQuery expects a HQL query
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#createQuery(
java.lang.String)
If you really, really want to do the create by hand, you should use
the method createSQLQuery, which takes an SQL query as parameter.
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#createSQLQue
ry(java.lang.String)
/Steen
aDeamon - 07 May 2007 12:53 GMT
> > CREATE TABLE table_name (id biginteger, name varchar(50))
>
[quoted text clipped - 15 lines]
>
> /Steen
Yes I tryed this to...
Session session =
HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
String query = "CREATE TABLE testTable (id INTEGER NOT NULL
PRIMARY KEY AUTO_INCREMENT, col VARCHAR(255))";
session.createSQLQuery(query);
...the problem then is that the table dose not show up in the table
afterwards. In MySQL the command "show tables;" show nothing.
Is there some configuration that I need to set?
/Sam
steen - 07 May 2007 19:37 GMT
> Yes I tryed this to...
>
[quoted text clipped - 6 lines]
>
> session.createSQLQuery(query);
Hint: remember to execute the query. The code you pasted just creates
the query...it doesn't actually execute it unless u ask it to.
/Steen
aDeamon - 08 May 2007 21:54 GMT
> > Yes I tryed this to...
>
[quoted text clipped - 11 lines]
>
> /Steen
LOL - I noticed that, how stuipd am I...
thanks anyway. Sometimes the obvius are to obvius to see..
/Sam