java - How to intercept hibernate query by column type -
i trying intercept hibernate query execution, here hibernate mapping
<class name="com.model.parent" table="parent" optimistic-lock="version" dynamic-update="true" dynamic-insert="true" lazy="true" > <property name="id" type="org.hibernate.usertype.usertype" column="object_id" /> ( here usertype guid format).....
if generated query following
select * parent p_ p_.id = ? or p_.id in (?,?,?)
need replace ?
hextoraw(?)
tables (columns defined raw). required query should this
select * parent p_ p_.id = hextoraw(?) or p_.id in (hextoraw(?),hextoraw(?),hextoraw(?))
since working existing system, can't change database column types.
how find columns defined raw on query execution (if use interceptors or other filters)? , how apply hextoraw() on found columns?
you can use interceptor.onpreparestatement , register sessionfactory
but have make sure interceptor modifies required field parameters hextoraw() not all.
Comments
Post a Comment