0

The alter column data type syntax in postgresql is :

ALTER TABLE table_name 
ALTER COLUMN column_name 
TYPE newType USING (column_name::newType)

I'm trying to use it via hibernate's SQLQuery to manage some dynamically created tables. The problem is hibernate sees ::newType as being parameters and throws a parameter not found error, and if I don't use casting postgres throws another error asking me to cast the type.

Is there any way of achieving this via hibernate?

2
  • have you tried with USING (column_name\\:\\:newType)? I think i have seen sth like this before Commented Jul 11, 2016 at 10:06
  • @Apostolos It works. I tried looking up the hibernate escape character but couldn't find it, I never assumed it would be just the basic java escape. Please post it as an answer so I can accept it. Commented Jul 11, 2016 at 14:29

1 Answer 1

1

Please escape the :: like this

USING (column_name\\:\\:newType)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.