ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akins, Greg" <Greg.Ak...@am.sony.com>
Subject RE: Customizing Parameter mapping
Date Fri, 29 Jul 2005 19:20:23 GMT
 insert into products (product_id, price, category_id, description)
    values (#productId#, #price#, #category.catetoryId#,
#category.description#)

 

-----Original Message-----
From: sreenivas [mailto:ko_srinivas@rediffmail.com] 
Sent: Friday, July 29, 2005 3:18 PM
To: user-java@ibatis.apache.org
Subject: Customizing Parameter mapping


Hi All,
 
I have requirement where a Java Bean has properties of user defined
objects.
 
Here is an example class called Product, where I have a property of type
"Category" class. All the properties of the product object are set &
passed to SQLMAP as a parameter class. Having said that I would like to
know syntax to instruct SQLMAP engine, to extract properties not only
from Product class, but also from Category class.
 
Here is XML snippet:
 
<insert id="insertInto" parameterClass="com.ic.ro.Product">
    insert into products (product_id, price, category_id, description)
    values (#productId#, #price#, # #) -- how to extract category_id &
description that are part of Category object, which is another property
in Product Bean?
    </insert>
 
Please see below bean definitions and let me know your comments &
suggestions.
 
Thanks and regards,
Srini
 
public class Product impements Serializable
{
 private String productId = null;
 private int price = 0;
 private Category cat = null;
 
 public String getProductId()
 {
  // TO DO
  return productId;
 }
 public void setProductId(String productid)
 {
  // TO DO
 }
 
 public int getPrice()
 {
  // TO DO
  return price;
 }
 public void setPrice(int price)
 {
  // TO DO
 }
 
 public Category getCategory()
 {
  // TO DO
  return cat;
 }
 public void setCategory(Category cat)
 {
  // TO DO
 }
 
}
 
***********     Category.java ******************
 
public class Category
{
 private int categoryId = 0;
 private String description = 0;
 
 public int getCategoryId()
 {
  // TO DO
  return categoryId;
 }
 public void getCategoryId(int cat)
 {
  // TO DO
 }
 public String getDescription()
 {
  // TO DO
  return description;
 }
 public void setDescription(String desc)
 {
  // TO DO
 }
 
}



Mime
View raw message