Ibatis Example!

xiaoxiao2021-03-06  64

Transfer from: http://www.ibatis.comwhat does a mapped statement look like? (Updated for 2.0!)

A feature of the sql map framework what allows columns aliases to becomings

Automatically mapped to javabeans proties. Imagine That The Address

Class Has The Properties: ID (INT), Description (String), Street (String),

CITY (STRING), And Postalcode (String). by use of column

Aliases in the sql statement (a standard sql feature) and naming the

Class in The Result-Class Attribute, The Values ​​in The Columns Will B

Automatically mapped to the javabean! this is just one way to get an

Object (javabean) from an SQL Query Using The SQL MAP Framework. ->

Resultclass = "Examples.domain.Product">

SELECT

PrD_ID AS ID,

PrD_category as category,

PrD_DESCRIPTION As Description,

PrD_retail as retail,

PrD_quantity as quantity

From product

Where prd_category = # value #

// Executing The Above Statement for a list of products

// in the "Dog" category is as simple as this:

String category = "DOG";

List productlist = sqlmap.queryforList ("getProductBycategory", category;

/ / TOO MANY RESULTS? How About a fully navigatable,

// lazy-loaded, Paginated List of Products That's

// javabeans Compliant and Easily Usable from With

// a JSP Page? Is 10 per page okay?

PaginatedList ProductList = SQLMap.QueryforList ("getProductBycategory", category,

10);

ProductList.nextpage ();

ProductList.Previouspage ();

ProductList.isnexTPageavailable ();

// ETC.

// NEED A MAP of Just The Product IDS and Descriptions from

// The Same Query?

Map descriptionMap = SQLMap.QueryFormap ("getProductBycategory",

Category,

"ID",

"description");

For example, Maybe you need to flatten out a

COMPLEX PARENT / CHILD TREE Using ORACLE? ->

CopyRight © 2020 All Rights Reserved
Processed: 0.041, SQL: 9