ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zeltner Martin <martin.zelt...@elca.ch>
Subject RE: How to know the column name when I have the property name?
Date Fri, 23 Dec 2005 07:41:27 GMT
How does I get the column name by using dynamic sql tags? Do you have an
example?

Martin 

-----Original Message-----
From: Larry Meadors [mailto:lmeadors@apache.org]
Sent: Donnerstag, 22. Dezember 2005 18:31
To: user-java@ibatis.apache.org
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 <martin.zeltner@elca.ch> 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
>
>

Mime
View raw message