|
IBATIS mappings are with _expression_
language support. You can access bean properties via dots,
which means that if your SumeaProject has public getTrack
and setTrack in your mappings you can use “track.track_id” as property name. From your code it follows that you have
to create public setter and getter for your Track in Project and track_id in
Track. Best, From: Andreas
Prudzilko [mailto:[EMAIL PROTECTED] Hello, I know this is a very basic question, so I hope I wasn’t
just too stupid to find the right place to read it up. I created a simple Model class Project extends GenericObject { .. Protected Track track; … } Now both Project and Track are mapped on tables, where the
project table has an indexed track_id column for a 1:1 relation between those
two. I want to insert a new Project to the Db by doing something
along the lines of this: ProductionTrack track = (ProductionTrack)
client.queryForObject("ProductionTrack.getTrack", 1); SumeaProject project = new SumeaProject("test",
new Date(), new Date(), track); client.insert("Project.insert", project); My mapping looks as follows: …. <parameterMap id="projectMap"
class="com.sumea.timemachine.model.SumeaProject">
<parameter property="id" jdbcType="INT"
javaType="int"/>
<parameter property="name" jdbcType="VARCHAR"
javaType="java.lang.String"/>
<parameter property="startDate" jdbcType="DATE"
javaType="java.util.Date"/>
<parameter property="endDate" jdbcType="DATE"
javaType="java.util.Date"/>
<parameter property="color" jdbcType="INT"
javaType="java.awt.Color"/>
<parameter property="track" ***what comes here?***/> </parameterMap> <insert id="insert"
parameterClass="com.sumea.timemachine.model.SumeaProject"
parameterMap="projectMap">
INSERT INTO
project (project_id, name, startdate, enddate, color, track_id)
VALUES (#id#, #name#, #startDate#, #endDate#, #color#, #track#) </insert> …. Now I wonder how to map the Track object on the track_id (int)
column. Do I need to write my own TypeHandler for that? Thanks for help in advance, Andreas Andreas Prudzilko Tools Developer
|
