How does I get the column name by using dynamic sql tags? Do you have an example?
Martin -----Original Message----- From: Larry Meadors [mailto:[EMAIL PROTECTED] Sent: Donnerstag, 22. Dezember 2005 18:31 To: [email protected] Subject: Re: How to know the column name when I have the property name? Look into the dynamic sql tags. Larry On 12/22/05, Zeltner Martin <[EMAIL PROTECTED]> wrote: > Hello everybody, > > As in Hibernate I'd like to have something flexible in Ibatis to execute > searches. For that I've got an array of criteria objects. Such a criteria > can look like this: > > public class Criteria { > private String field; > private Object value; > private String sqlOperator; > > public String getSqlCriteria() { > return field + " " + sqlOperator + " " + value; > } > > // plus getter and setter for the properties above. > } > > > By this Ibatis can combine an sql with the given criteria object by using > property #sqlCriteria#. > > The problem is now that I don't know the correct column name (field). I just > know the property name of my bean that don't have to be the same. Example: > > public class MyBean { > private int key; > > public String getKey() {...} > public void setKey(int key) {...} > ... > } > > CREATE TABLE mytable ( > keyid INTEGER NOT NULL PRIMARY KEY, > ... > ); > > So I just know that the property name is "key" but I don't know that in > database the column has name "keyid". > > How get I know this? > OR, does somebody can tell me a solution where I can pass the criteria array > directly to Ibatis without using method "getSqlCriteria"? > > Thanks a lot for any comments! > > Best regards, > Martin > >
