ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Givler, Eric" <egiv...@state.pa.us>
Subject RE: mutiple parameters in query
Date Fri, 22 Aug 2008 01:57:08 GMT
Try adding parameterClass="map" in the ibatis mapping.
In the calling code, add:

Map params = new HashMap();
map.put("cod", codeParameterValue );
map.put("name", nameParameterValue );
Car car = (Car) sqlMap.queryForObject("getCar", params );

Let me know how this works out since I'm not at work to test this.
Eric
________________________________________
From: jesid [javav112@gmail.com]
Sent: Thursday, August 21, 2008 7:17 PM
To: user-java@ibatis.apache.org
Subject: mutiple parameters in query

I need know how send the parameters to query if the query have more than 1
table, for example:

<select id="getCar" resultClass="co.enti.Car">
   SELECT
       car.COD_CAR as cod,
       per.NAME as name
   FROM
       IPS_CARA car,
       IPS_PERSON per
   WHERE
       car.COD_CAR = #cod# AND
       per.NAME like '%$name$%'
</select>


I´m sending the parameters this way



Car car = (Car) sqlMap.queryForObject("getCar", ???????);   ---- > here is
that I need help


and the bean from the table IPS_CARA, Car is for example:

public class Car {
     private String model;
   private int cod;
   private int codPer;

   public int getCodPer() {
       return codPer;
   }
   public void setCodPer(int codPer) {
       this.codPer = codPer;
   }

   public int getCod() {
       return cod;
   }
   public void setCod(int cod) {
       this.cod = cod;
   }

   public int getModel() {
       return model;
   }
   public void setModel(int model) {
       this.model = model;
   }

}

and IPS_PERSON is

public class Person {
     private String name;
   private String lastName;
   private int codPer;

   public int getCodPer() {
       return codPer;
   }
   public void setCodPer(int codPer) {
       this.codPer = codPer;
   }

   public String getName() {
       return cod;
   }
   public void setName(String name) {
       this.name = name;
   }

   public String getLastName() {
       return lastName;
   }
   public void setLastName(String lastName) {
       this.lastName = lastName;
   }

}

thank....:handshake:
--
View this message in context: http://www.nabble.com/mutiple-parameters-in-query-tp19098786p19098786.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message