java - Mapping Composition in MyBatis -


i'm having trouble mapping in mybatis java , appreciate help. class structure below:

//getters/setters omitted clarity  class foo  {   int id;   bar bar; }  class bar {   string x;   int y; } 

my table looks - i.e. de-normalized class structure.

create table foo_bar (   id int,   x varchar,   y int ); 

my working insert statement able de-normalize using (bar.x, bar.y) parameters.

<insert id="insert" parametertype="foo">   <![cdata[     insert foo_bar     (id, x, y) values     (#{x}, #{bar.x}, #{bar.y})   ]]> </insert> 

so, problem:

when execute select, resultant object instance of foo has reference bar.

i don't think can use type handler since works on single column, , and association doesn't seem make sense since 'bar' not entity explicitly represented in database via foreign key relationship.

can show me recommended way of doing please?

thanks!

have tried using resultmap definition in ibatis sqlmap?

<resultmap id="foobar-result" class="foo">     <result property="id" column="id"/>     <result property="bar.x" column="x"/>     <result property="bar.y" column="y"/> </resultmap> 

and in sql reference resultmap:

<select id="getfoobar" resultmap="foobar-result"> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -