IBATIS - Usage

Usage

For example, assume there is a database table PRODUCT (PROD_ID INTEGER, PROD_DESC VARCHAR(64)) and a Java class com.example.Product (id: int, description: String). To read the product record having the key PROD_ID into a new Product POJO, the following mapping is added into an iBATIS XML mapping file:

A new Java Product object can then be retrieved from the database for product number 123 as follows:

Product resultProduct = (Product) sqlMapClient.queryForObject("getProduct", 123);

In the mapping file example, #value# refers to the long integer value passed into the query. If the parameter is a Java object, then values from properties on that object can be inserted into the query using a similar # notation. For example, if the parameter class is a com.example.Product which has a property called id, then #value# can be replaced with #id#. The sqlMapClient object is an instance of class com.ibatis.sqlmap.client.SqlMapClient.

Read more about this topic:  IBATIS

Famous quotes containing the word usage:

    I am using it [the word ‘perceive’] here in such a way that to say of an object that it is perceived does not entail saying that it exists in any sense at all. And this is a perfectly correct and familiar usage of the word.
    —A.J. (Alfred Jules)

    ...Often the accurate answer to a usage question begins, “It depends.” And what it depends on most often is where you are, who you are, who your listeners or readers are, and what your purpose in speaking or writing is.
    Kenneth G. Wilson (b. 1923)

    Pythagoras, Locke, Socrates—but pages
    Might be filled up, as vainly as before,
    With the sad usage of all sorts of sages,
    Who in his life-time, each was deemed a bore!
    The loftiest minds outrun their tardy ages.
    George Gordon Noel Byron (1788–1824)