tags:

views:

33

answers:

1

Hello, I have two tables 1 is "contact_info" - having fields like (owner_id, contact_type, contact_value), another one is "contact" -having fields like (id, f_name, l_name, email). Now i want to insert into contact_info with the reference from table contact- id.

I am using code as below...

//=======Contact.xml============//

<insert id="insert_con_info" parameterClass="Contact">
  INSERT INTO CONTACT_INFO(OWNER_ID, CONTACT_TYPE, CONTACT_VALUE)
  VALUES((SELECT ID FROM CONTACT WHERE ID=#id#), #contact_type#, #contact_value#);
 </insert>

And Main Class contain code as below...

Contact con = new Contact(2,"Office", 12345678);
      sqlMap.insert("Contact.insert_con_info", con);

But it throws exception like

"There is no READABLE property named 'contact_type' in class 'Contact'"

please give me suggestion if possible

Thanks in Advance...

A: 

Try:

<insert id="insert_con_info" parameterClass="Contact">
  INSERT INTO CONTACT_INFO(OWNER_ID, CONTACT_TYPE, CONTACT_VALUE)
  SELECT ID, #contact_type#, #contact_value# FROM CONTACT WHERE ID=#id#;
</insert>
Martin