[odb-users] How to Modify ODB template by generate code

Justlive duhai_lee at qq.com
Sun Dec 9 22:36:02 EST 2012


<div>Hi,</div><div>&nbsp; &nbsp; I used odb version is 2.0.1. My compiler is vc2003, OS is windows 7. Generate code by ODB command, compily it, then make a mistake...</div><div><br></div><div>I must modify it like this:</div><div><br></div><div><div>&nbsp;result&lt; access::object_traits&lt; ::OilField &gt;::object_type &gt;</div><div>&nbsp; access::object_traits&lt; ::OilField &gt;::</div><div>&nbsp; query (database&amp;, const query_base_type&amp; q)</div><div>&nbsp; {</div><div>&nbsp; &nbsp; //using namespace mysql; &nbsp; // comment this line..</div><div>&nbsp; &nbsp; using odb::details::shared;</div><div>&nbsp; &nbsp; using odb::details::shared_ptr;</div><div><br></div><div>&nbsp; &nbsp; mysql::connection&amp; conn (</div><div>&nbsp; &nbsp; &nbsp; mysql::transaction::current ().connection ());</div><div><br></div><div>&nbsp; &nbsp; statements_type&amp; sts (</div><div>&nbsp; &nbsp; &nbsp; conn.statement_cache ().find_object&lt;object_type&gt; ());</div><div><br></div><div>&nbsp; &nbsp; image_type&amp; im (sts.image ());</div><div>&nbsp; &nbsp; mysql::binding&amp; imb (sts.select_image_binding ()); &nbsp;// add&nbsp;mysql:: namespace</div><div><br></div><div>&nbsp; &nbsp; if (im.version != sts.select_image_version () ||</div><div>&nbsp; &nbsp; &nbsp; &nbsp; imb.version == 0)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; bind (imb.bind, im, mysql::statement_select);&nbsp;&nbsp;// add&nbsp;mysql:: namespace</div><div>&nbsp; &nbsp; &nbsp; sts.select_image_version (im.version);</div><div>&nbsp; &nbsp; &nbsp; imb.version++;</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; shared_ptr&lt;mysql::select_statement&gt; st ( &nbsp;&nbsp;// add&nbsp;mysql:: namespace</div><div>&nbsp; &nbsp; &nbsp; new (shared) mysql::select_statement ( &nbsp; &nbsp;&nbsp;// add&nbsp;mysql:: namespace</div><div>&nbsp; &nbsp; &nbsp; &nbsp; sts.connection (),</div><div>&nbsp; &nbsp; &nbsp; &nbsp; query_statement + q.clause (),</div><div>&nbsp; &nbsp; &nbsp; &nbsp; q.parameters_binding (),</div><div>&nbsp; &nbsp; &nbsp; &nbsp; imb));</div><div><br></div><div>&nbsp; &nbsp; st-&gt;execute ();</div><div><br></div><div>&nbsp; &nbsp; shared_ptr&lt; odb::object_result_impl&lt;object_type&gt; &gt; r (</div><div>&nbsp; &nbsp; &nbsp; new (shared) mysql::object_result_impl&lt;object_type&gt; (</div><div>&nbsp; &nbsp; &nbsp; &nbsp; q, st, sts));</div><div><br></div><div>&nbsp; &nbsp; return result&lt;object_type&gt; (r);</div><div>&nbsp; }</div></div><div><br></div><div>then, &nbsp;it works.</div><div>of course, if I would't modify it, it works good on vs2010.&nbsp;</div><div><br></div><div>so, I hope I can modify template of generating code . &nbsp;else I modify it what generated code every time I modify my entity class.&nbsp;</div><div>but I can't found that to change the template. It's just a odb.exe.&nbsp;</div><div><br></div><div>thanks..</div><div><br></div><div><br></div>


More information about the odb-users mailing list