ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vikram Subbarao <vikra...@directi.com>
Subject Re: java.util.UUID to postgres uuid column
Date Thu, 11 Feb 2010 08:12:49 GMT
Does not work -

    com.ibatis.common.beans.ProbeException: There is no READABLE 
property named 'value' in class 'java.util.UUID'

Niels Beekman wrote:
>
> Try #value#, this will use your parameter object directly. Using #id# 
> tries to obtain the id property from it.
>
>  
>
> ------------------------------------------------------------------------
>
> *From:* Vikram Subbarao [mailto:vikram.s@directi.com]
> *Sent:* Thursday, February 11, 2010 7:50 AM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: java.util.UUID to postgres uuid column
>
>  
>
> With this approach i tried this in a query -
>
>     <select id="findById" parameterClass="java.util.UUID" 
> resultMap="fullResult" cacheModel="cache">
>         SELECT users.*
>         FROM users
>         WHERE id = #id#
>     </select>   
>
>
> When i call this query as -
>
>     sqlMapClientTemplate.queryForObject("User.findById", id);
>
> /    Note: id is an java.util.UUID object./
>
> I get an error -
>
>     com.ibatis.common.beans.ProbeException: There is no READABLE 
> property named 'id' in class 'java.util.UUID'
>
> Regards
> Vikram
>
> Larry Meadors wrote:
>
> This might work:
>  
> public class UUIDTypeHandler implements TypeHandlerCallback {
>     @Override
>     public void setParameter(ParameterSetter setter, Object parameter)
> throws SQLException {
>         setter.setObject(parameter);
>     }
>  
>     @Override
>     public Object getResult(ResultGetter getter) throws SQLException {
>         return getter.getObject();
>     }
>  
>     @Override
>     public Object valueOf(String s) {
>         return UUID.fromString(s);
>     }
> }
>  
> Add this in your sqlmapconfig.xml:
>  
> <typeAlias alias="UUID" type="java.util.UUID" />
> <typeHandler javaType="UUID" callback="UUIDTypeHandler"/>
>  
> Larry
>  
>  
>  
> On Tue, Feb 9, 2010 at 3:35 AM, Vikram Subbarao <vikram.s@directi.com> <mailto:vikram.s@directi.com>
wrote:
>   
>> I am using postgres db and would like to map a java.util.UUID to a postgres
>> uuid column. Latest postgres driver supports mapping of this if i was
>> directly creating my prepared statements but since i use ibatis inbetween, i
>> am unable to achive this as ibatis does not seem to understand that
>> java.util.UUID can be based down to jdbc. I could use typehandler if the db
>> column was a VARCHAR, but since the postgres db is a 'uuid' type, i have  no
>> option but to use the driver supported option of using java.util.UUID, but
>> it does not work with ibatis for me.
>>  
>> Please help me if some one has a solution to this.
>>  
>> Regards
>> Vikram
>>  
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org <mailto:user-java-unsubscribe@ibatis.apache.org>
>> For additional commands, e-mail: user-java-help@ibatis.apache.org <mailto:user-java-help@ibatis.apache.org>
>>  
>>  
>>     
>  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org <mailto:user-java-unsubscribe@ibatis.apache.org>
> For additional commands, e-mail: user-java-help@ibatis.apache.org <mailto:user-java-help@ibatis.apache.org>
>  
>   

Mime
View raw message