tags:

views:

26

answers:

2

I tried session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate();

but this throws org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query

After a lot of googling, the recommendation is to use HQL instead of SQL query to do bulk updates. Not sure how to use HQL to accomplish this. There seems to be no decent HQL documentation for updating column length in a table.

Thanks so much for the help.

A: 

I suggest you to run this native SQL query via session.connection().

See section 16.2.2.1. Rules/limitations for using stored procedures of Chapter 16. Native SQL, it's near your ALTER query.

All the rest depends on your database vendor. Good Luck!

SergeanT
A: 

I could not find a way. Looks like a limitation. I added a new field and copied over data from old field at start-up!

Gmu