开发者

Type casting in Hibernate for column in Informix database

开发者 https://www.devze.com 2023-01-22 18:34 出处:网络
I am using Informix for a OR database and Spring + Hibernate on the backend of my application. The thing is, I make in a String variable the query that inserts data in the database table. In this quer

I am using Informix for a OR database and Spring + Hibernate on the backend of my application. The thing is, I make in a String variable the query that inserts data in the database table. In this query string I'm using type casting for some columns (something like this: ..ROW(street,city,country)::addressT.. where addressT is the type I made in the database).

The problem here lays in Hibernates createSQLQuery(String query) method. When I pass it the query string, it automatically searches in that string for named parameters (:namedParameter - so the "colon" sign and the name of the parameter) and tries to replace it with something. The result is a query like this: ...ROW(street,city,country)?...

Is there any way to disable hibernates automatic named parameter replacement or is 开发者_开发知识库there any other way to forward the native query to my Informix database?


You might be able to use the CAST(<expression> AS <type>) notation.

Beware of other system's adamant insistence that 'db@server:owner.table' or 'DATETIME(12:13:14) YEAR TO SECOND' contain placeholders, not legitimate Informix syntactic constructs.

0

精彩评论

暂无评论...
验证码 换一张
取 消