uuid custom typehandler mybatis -


i want manage table varchar primary key, in mapped java object should uuid.

i have sql-map-config.xml:

<?xml version="1.0" encoding="utf-8" ?> <!doctype configuration    public "-//mybatis.org//dtd config 3.0//en"    "http://mybatis.org/dtd/mybatis-3-config.dtd">  <configuration>        <properties resource="database.properties"/>    <typehandlers>        <typehandler handler="[...].persistence.typehandlers.uuidtypehandler"                     javatype="java.util.uuid"                     jdbctype="varchar"/>    </typehandlers>        <environments default="development">                <environment id="development">                        <transactionmanager type="jdbc" />                        <datasource type="pooled">                                <property name="driver" value="${driver}" />                                <property name="url" value="${url}" />                                <property name="username" value="${username}" />                                <property name="password" value="${password}" />                        </datasource>                </environment>        </environments>        <mappers>                <mapper resource="user.xml" />    </mappers> </configuration> 

and user.xml that:

<?xml version="1.0" encoding="utf-8" ?> <!doctype mapper        public "-//mybatis.org//dtd mapper 3.0//en"        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  <mapper namespace="[...].persistence.mappers.usermapper">     <select id="selectuserbyuuid" parametertype="java.util.uuid" resultmap="userresultmap">        select * user uuid = #{uuid, jdbctype=varchar, typehandler=[...].persistence.typehandlers.uuidtypehandler}    </select>    <resultmap id="userresultmap" type="[...].model.user">        <id property="uuid" column="uuid" jdbctype="other" typehandler="[...].persistence.typehandlers.uuidtypehandler"/>        ...    </resultmap> </mapper> 

anyway, got exception:

org.apache.ibatis.exceptions.persistenceexception: ### error querying database.  cause: org.apache.ibatis.reflection.reflectionexception: there no getter property named 'uuid' in 'class java.util.uuid' ### error may involve [...].persistence.mappers.usermapper.selectuserbyuuid-inline ### error occurred while setting parameters ### cause: org.apache.ibatis.reflection.reflectionexception: there no getter property named 'uuid' in 'class java.util.uuid' 

it seems typehandler never gets called (i have logging bit, never prints anything). there wrong? thanks.

your problem right there in exception....

there no getter property named 'uuid' in 'class java.util.uuid' 

use parameter type of string, , pass in unique id argument. don't need type handler.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -