iBATIS is a persistence framework that automates mapping between SQL databases and objects in Java, .NET, and Ruby on Rails. It makes use of XML files to define SQL statements and mappings between objects and database tables in a way that is decoupled from application logic. iBATIS emphasizes the use of SQL and is regarded as one of the simplest frameworks available due to its philosophy of facilitating fast development through simplicity, portability, and independent interfaces.
iBATIS is a lightweight framework for mapping SQL and objects in Java. This document discusses how to perform CRUD operations using iBATIS. It describes creating a POJO class for an Employee table with fields like id, name, salary. An Employee.xml file defines SQL mappings - the <insert> tag maps an "insert" method to insert a record. The IbatisInsert Java file calls this method to insert a sample employee. Reading is similar, with <select> defining a method mapped to a SELECT query. The document covers all CRUD operations and additional iBATIS features.
Beta Soft Systems provides software development, ITES, staffing, consulting, and training services. It was established in 2005 in Fremont, California and 2008 in Panchkula, Haryana, India. The company's mission is to provide end-to-end business solutions and its values include respect, integrity, trust, exceptional service, commitment, and stewardship. Beta Soft Systems has received several awards and achievements for its work. It offers training modules in languages and technologies like C/C++, LAMP stack, web design, SEO, .NET, Java, and Android.
This document discusses properties and binding in JavaFX 2.0. It provides an overview of properties based on the JavaBeans model and how they are expanded in JavaFX. It describes the high-level and low-level binding APIs, with the high-level API providing simple bindings for common cases and the low-level API providing more flexibility. Examples are provided to demonstrate properties and binding functionality.
MyBatis is a persistence framework that automates mapping between SQL databases and objects in Java. This tutorial provides an overview of MyBatis and teaches how to perform CRUD operations using MyBatis including configuration files, mapping files, POJOs, and Java code. It also covers more advanced topics like annotations, stored procedures, and dynamic SQL.
Hibernate is an object-relational mapping tool for Java that takes care of mapping Java classes to database tables. It provides a simple API for storing and retrieving objects and handles common data persistence tasks. The core classes in Hibernate's architecture include Configuration, SessionFactory, and Session. Configuration handles configuration files and mappings. SessionFactory is a thread-safe object that is used to create Session instances. Session represents a conversation between the application and the database.
This is a introductory lecture of J2EE for those who want to learn what is j2ee technology and about its basics.You can also fine coding exmples in this lecture
This is my 2012-02-20 talk about LTI at Nottingham. It focused less on the technical aspects of LTI and more on the applications and uses of LTI. It featured a new video from WikiSpaces.
iBATIS is a lightweight framework for mapping SQL and objects in Java. This document discusses how to perform CRUD operations using iBATIS. It describes creating a POJO class for an Employee table with fields like id, name, salary. An Employee.xml file defines SQL mappings - the <insert> tag maps an "insert" method to insert a record. The IbatisInsert Java file calls this method to insert a sample employee. Reading is similar, with <select> defining a method mapped to a SELECT query. The document covers all CRUD operations and additional iBATIS features.
Beta Soft Systems provides software development, ITES, staffing, consulting, and training services. It was established in 2005 in Fremont, California and 2008 in Panchkula, Haryana, India. The company's mission is to provide end-to-end business solutions and its values include respect, integrity, trust, exceptional service, commitment, and stewardship. Beta Soft Systems has received several awards and achievements for its work. It offers training modules in languages and technologies like C/C++, LAMP stack, web design, SEO, .NET, Java, and Android.
This document discusses properties and binding in JavaFX 2.0. It provides an overview of properties based on the JavaBeans model and how they are expanded in JavaFX. It describes the high-level and low-level binding APIs, with the high-level API providing simple bindings for common cases and the low-level API providing more flexibility. Examples are provided to demonstrate properties and binding functionality.
MyBatis is a persistence framework that automates mapping between SQL databases and objects in Java. This tutorial provides an overview of MyBatis and teaches how to perform CRUD operations using MyBatis including configuration files, mapping files, POJOs, and Java code. It also covers more advanced topics like annotations, stored procedures, and dynamic SQL.
Hibernate is an object-relational mapping tool for Java that takes care of mapping Java classes to database tables. It provides a simple API for storing and retrieving objects and handles common data persistence tasks. The core classes in Hibernate's architecture include Configuration, SessionFactory, and Session. Configuration handles configuration files and mappings. SessionFactory is a thread-safe object that is used to create Session instances. Session represents a conversation between the application and the database.
This is a introductory lecture of J2EE for those who want to learn what is j2ee technology and about its basics.You can also fine coding exmples in this lecture
This is my 2012-02-20 talk about LTI at Nottingham. It focused less on the technical aspects of LTI and more on the applications and uses of LTI. It featured a new video from WikiSpaces.
This document provides an overview and tutorial for Hibernate, an open source object-relational mapping tool for Java. It begins with introductions to object-relational mapping, Hibernate's advantages, architecture, and environment setup. The bulk of the document then covers configuring Hibernate, using sessions to manage persistence, mapping Java objects to database tables, and examples of implementing different types of associations.
Hibernate is an open source object-relational mapping tool for Java that takes care of mapping Java objects to database tables and Java data types to SQL data types. It provides data query and retrieval facilities. This tutorial teaches how to use Hibernate to develop database-driven web applications in Java. It assumes knowledge of Java and basic understanding of relational databases and SQL.
This chapter introduces MyBatis, a persistence framework that simplifies database access in Java. It discusses why MyBatis is useful by eliminating JDBC boilerplate code and embracing SQL. The chapter then demonstrates how to install MyBatis, configure it with a sample database, create Java classes to interface with MyBatis and test the setup with a JUnit test. Key advantages of MyBatis like its low learning curve and support for integration with Spring are also covered at a high level.
This document provides instructions on setting up a Java development environment for Java Server Pages (JSP). It describes downloading the Java Development Kit (JDK), setting the PATH and JAVA_HOME environment variables. It also explains downloading and installing the Tomcat web server, and starting it to test JSP programs. The goal is to configure the necessary software for developing and running JSP applications.
This document provides an overview and tutorial on Java Server Pages (JSP) technology. It discusses what JSP is, its advantages, how to set up the development environment, the JSP architecture and lifecycle, basic syntax like scriptlets and directives, built-in objects, handling client requests and server responses, and form processing. The goal of the tutorial is to teach readers how to use JSP to develop dynamic web applications.
This document provides instructions on setting up a Java development environment for Java Server Pages (JSP). It describes downloading the Java Development Kit (JDK), setting the PATH and JAVA_HOME environment variables. It also explains downloading and installing the Tomcat web server, and starting it to test JSP programs. The goal is to configure the necessary software for developing and running JSP applications.
This document provides an overview of SQL (Structured Query Language). It covers topics such as what SQL is, the SQL process, common SQL commands, relational database concepts, different RDBMS databases that use SQL, SQL syntax, data types, operators, expressions, and how to create, manipulate and drop databases and tables using SQL statements. It also discusses SQL constraints, data integrity, database normalization forms, and provides examples of SQL queries for tasks like selecting, inserting, updating and deleting data.
This document provides an overview and introduction to SQL (Structured Query Language). It covers topics such as what SQL is, its basic commands, RDBMS concepts like database normalization, different SQL syntax like CREATE, SELECT, INSERT, and different SQL operators. It also provides examples of creating databases and tables, inserting, selecting, updating and deleting data from tables. The document is intended to give beginners a basic understanding of SQL and how it works.
The document discusses using Oracle TopLink as a persistence framework with EJB 3.0 and Java Persistence API (JPA). It provides an overview of persistence frameworks and their benefits, and outlines goals to develop an understanding of J2EE design, persistence frameworks, and how to develop a simple persistence framework using TopLink. The presentation also demonstrates creating Java entity objects from database tables using TopLink wizards in JDeveloper, and building a session bean to expose the entities and provide data access functionality.
Managing Data in Jakarta EE ApplicationsBuhake Sindi
In this talk, we will delve into the complexities of managing data in enterprise Java applications. Effective data management is crucial for maintaining the integrity, availability, and security of enterprise systems. Attendees will gain a deep understanding of various aspects related to data management, including data modeling, persistence frameworks, caching strategies, scalability, and data synchronization. Through real-world examples and best practices, this session aims to equip developers with the knowledge and tools necessary to efficiently handle data in their Java applications.
This document provides information about inplant training programs offered by KAASHIV INFOTECH in Chennai, India. It outlines 5-day training schedules for students of CSE/IT/MCA, ECE/EEE, and Mechanical/Civil engineering. The CSE/IT/MCA schedule focuses on topics like Big Data, app development, ethical hacking, and cloud computing. The ECE/EEE schedule covers embedded systems, wireless systems, and CCNA networking. The mechanical/civil schedule includes aircraft design, vehicle movement, and 3D modeling and packaging. The training is handled by professionals and aims to equip students with strong technical skills.
This document provides information about Venkatesan Prabu Jayakantham (Venkat), the Managing Director of KAASHIV INFOTECH, a software company in Chennai. It outlines Venkat's experience in Microsoft technologies and certifications. It also details the various awards he has received throughout his career. Finally, it advertises KAASHIV INFOTECH's inplant training programs for students in fields like computer science, electronics, and mechanical engineering.
Big data - ‘Big Data’ is similar to ‘small data’, but bigger in size.
But having data bigger it requires different approaches:Techniques, tools and architecture.
Web development- React.js,angular js,Vue.js
Mobile application development-API in mobile applications (cURL API),Develop in mobile applications (react-native)
elementary OS
Concurrency
YouTube Link: https://youtu.be/2sCAw1EbfEQ
Hibernate Certification: https://www.edureka.co/persistence-with-hibernate-self-paced
This Edureka PPT on "Hibernate Interview Questions" video will help you prepare for the role of a Hibernate Developer.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Full stack campus institute offers Java Coaching in Hyderabad with online training, hands-on, certification,100% job support and 10+ experience in Java program.
This document describes a MyFacebook social networking project created using Java and other web technologies. It includes chapters on tools and platforms used, requirements, system design including DFD, ER diagram and use case diagram, screenshots of key pages, testing approach and future enhancements. The project aims to provide a local social network for college students and faculty for secure communication within the college network.
This document provides an overview and introduction to SQL (Structured Query Language). SQL is a language used to manage and retrieve data stored in relational databases. The tutorial covers SQL concepts like data definition, manipulation, and control languages. It also discusses SQL database concepts, different RDBMS systems like MySQL, SQL Server, and Oracle, and SQL syntax for queries, statements to create/alter tables, and more. The goal is to give beginners a quick start in learning the basics of SQL.
This document provides an overview of Apache Tika, including what it is, its applications, architecture, supported file formats, and how it detects document types. Apache Tika is a toolkit for detecting and extracting metadata and structured text content from various documents. It supports many common file types and formats and provides APIs for applications to integrate document parsing and metadata extraction. Tika detects file types using techniques like file extensions, MIME type hints, and identifying magic bytes within files. It then extracts text content and metadata using parser plugins for each supported file format.
The document discusses how to integrate SQLite with Perl using the DBI module. It provides steps to install DBI and SQLite drivers for Perl and describes important DBI APIs to connect to a SQLite database, execute SQL statements, and perform CRUD (create, read, update, delete) operations. Code examples are given to create a database, table, insert, select, update, and delete records.
This document provides an overview and tutorial for Hibernate, an open source object-relational mapping tool for Java. It begins with introductions to object-relational mapping, Hibernate's advantages, architecture, and environment setup. The bulk of the document then covers configuring Hibernate, using sessions to manage persistence, mapping Java objects to database tables, and examples of implementing different types of associations.
Hibernate is an open source object-relational mapping tool for Java that takes care of mapping Java objects to database tables and Java data types to SQL data types. It provides data query and retrieval facilities. This tutorial teaches how to use Hibernate to develop database-driven web applications in Java. It assumes knowledge of Java and basic understanding of relational databases and SQL.
This chapter introduces MyBatis, a persistence framework that simplifies database access in Java. It discusses why MyBatis is useful by eliminating JDBC boilerplate code and embracing SQL. The chapter then demonstrates how to install MyBatis, configure it with a sample database, create Java classes to interface with MyBatis and test the setup with a JUnit test. Key advantages of MyBatis like its low learning curve and support for integration with Spring are also covered at a high level.
This document provides instructions on setting up a Java development environment for Java Server Pages (JSP). It describes downloading the Java Development Kit (JDK), setting the PATH and JAVA_HOME environment variables. It also explains downloading and installing the Tomcat web server, and starting it to test JSP programs. The goal is to configure the necessary software for developing and running JSP applications.
This document provides an overview and tutorial on Java Server Pages (JSP) technology. It discusses what JSP is, its advantages, how to set up the development environment, the JSP architecture and lifecycle, basic syntax like scriptlets and directives, built-in objects, handling client requests and server responses, and form processing. The goal of the tutorial is to teach readers how to use JSP to develop dynamic web applications.
This document provides instructions on setting up a Java development environment for Java Server Pages (JSP). It describes downloading the Java Development Kit (JDK), setting the PATH and JAVA_HOME environment variables. It also explains downloading and installing the Tomcat web server, and starting it to test JSP programs. The goal is to configure the necessary software for developing and running JSP applications.
This document provides an overview of SQL (Structured Query Language). It covers topics such as what SQL is, the SQL process, common SQL commands, relational database concepts, different RDBMS databases that use SQL, SQL syntax, data types, operators, expressions, and how to create, manipulate and drop databases and tables using SQL statements. It also discusses SQL constraints, data integrity, database normalization forms, and provides examples of SQL queries for tasks like selecting, inserting, updating and deleting data.
This document provides an overview and introduction to SQL (Structured Query Language). It covers topics such as what SQL is, its basic commands, RDBMS concepts like database normalization, different SQL syntax like CREATE, SELECT, INSERT, and different SQL operators. It also provides examples of creating databases and tables, inserting, selecting, updating and deleting data from tables. The document is intended to give beginners a basic understanding of SQL and how it works.
The document discusses using Oracle TopLink as a persistence framework with EJB 3.0 and Java Persistence API (JPA). It provides an overview of persistence frameworks and their benefits, and outlines goals to develop an understanding of J2EE design, persistence frameworks, and how to develop a simple persistence framework using TopLink. The presentation also demonstrates creating Java entity objects from database tables using TopLink wizards in JDeveloper, and building a session bean to expose the entities and provide data access functionality.
Managing Data in Jakarta EE ApplicationsBuhake Sindi
In this talk, we will delve into the complexities of managing data in enterprise Java applications. Effective data management is crucial for maintaining the integrity, availability, and security of enterprise systems. Attendees will gain a deep understanding of various aspects related to data management, including data modeling, persistence frameworks, caching strategies, scalability, and data synchronization. Through real-world examples and best practices, this session aims to equip developers with the knowledge and tools necessary to efficiently handle data in their Java applications.
This document provides information about inplant training programs offered by KAASHIV INFOTECH in Chennai, India. It outlines 5-day training schedules for students of CSE/IT/MCA, ECE/EEE, and Mechanical/Civil engineering. The CSE/IT/MCA schedule focuses on topics like Big Data, app development, ethical hacking, and cloud computing. The ECE/EEE schedule covers embedded systems, wireless systems, and CCNA networking. The mechanical/civil schedule includes aircraft design, vehicle movement, and 3D modeling and packaging. The training is handled by professionals and aims to equip students with strong technical skills.
This document provides information about Venkatesan Prabu Jayakantham (Venkat), the Managing Director of KAASHIV INFOTECH, a software company in Chennai. It outlines Venkat's experience in Microsoft technologies and certifications. It also details the various awards he has received throughout his career. Finally, it advertises KAASHIV INFOTECH's inplant training programs for students in fields like computer science, electronics, and mechanical engineering.
Big data - ‘Big Data’ is similar to ‘small data’, but bigger in size.
But having data bigger it requires different approaches:Techniques, tools and architecture.
Web development- React.js,angular js,Vue.js
Mobile application development-API in mobile applications (cURL API),Develop in mobile applications (react-native)
elementary OS
Concurrency
YouTube Link: https://youtu.be/2sCAw1EbfEQ
Hibernate Certification: https://www.edureka.co/persistence-with-hibernate-self-paced
This Edureka PPT on "Hibernate Interview Questions" video will help you prepare for the role of a Hibernate Developer.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Full stack campus institute offers Java Coaching in Hyderabad with online training, hands-on, certification,100% job support and 10+ experience in Java program.
This document describes a MyFacebook social networking project created using Java and other web technologies. It includes chapters on tools and platforms used, requirements, system design including DFD, ER diagram and use case diagram, screenshots of key pages, testing approach and future enhancements. The project aims to provide a local social network for college students and faculty for secure communication within the college network.
This document provides an overview and introduction to SQL (Structured Query Language). SQL is a language used to manage and retrieve data stored in relational databases. The tutorial covers SQL concepts like data definition, manipulation, and control languages. It also discusses SQL database concepts, different RDBMS systems like MySQL, SQL Server, and Oracle, and SQL syntax for queries, statements to create/alter tables, and more. The goal is to give beginners a quick start in learning the basics of SQL.
This document provides an overview of Apache Tika, including what it is, its applications, architecture, supported file formats, and how it detects document types. Apache Tika is a toolkit for detecting and extracting metadata and structured text content from various documents. It supports many common file types and formats and provides APIs for applications to integrate document parsing and metadata extraction. Tika detects file types using techniques like file extensions, MIME type hints, and identifying magic bytes within files. It then extracts text content and metadata using parser plugins for each supported file format.
The document discusses how to integrate SQLite with Perl using the DBI module. It provides steps to install DBI and SQLite drivers for Perl and describes important DBI APIs to connect to a SQLite database, execute SQL statements, and perform CRUD (create, read, update, delete) operations. Code examples are given to create a database, table, insert, select, update, and delete records.
This document provides an overview of the Sqoop tool, which is used to transfer data between Hadoop and relational database servers. Sqoop can import data from databases into HDFS and export data from HDFS to databases. The document describes how Sqoop works, provides installation instructions, and outlines various Sqoop commands for import, export, jobs, code generation, and interacting with databases.
This document provides an overview and introduction to XPath. It explains that XPath is a query language used for traversing and searching XML documents by defining patterns to select nodes. The document consists of multiple chapters that will explain the basic components of XPath through examples, including XPath expressions, nodes, absolute and relative paths, axes, operators, wildcards, and predicates. It is intended for beginners to help them understand the fundamental concepts of XPath. Some basic knowledge of XML, HTML, and JavaScript is recommended.
<SUMMARY>
This document provides an overview of XML and discusses its basic syntax and structure. It defines XML as a markup language derived from SGML used to identify data. It then explains that XML tags are used to store and organize data rather than display it like HTML tags. Finally, it outlines the key sections of an XML document, including the prolog, root element, and child elements used to divide the document.
</SUMMARY>
This document provides an overview of XML Schema Definition (XSD). It discusses that XSD is used to describe and validate the structure and vocabulary of an XML document. It then provides an example of a simple XSD code and explains some of its key features, such as being extensible, supporting data types and namespaces. It also outlines the basic syntax of an XSD, including the required <schema> root element and optional attributes like targetNamespace. Finally, it demonstrates how to reference an external XSD from an XML document using schemaLocation.
This document is a tutorial that introduces the basics of XSLT (eXtensible Stylesheet Language Transformations). It explains that XSLT is used to transform XML documents into other formats like XHTML. The tutorial contains chapters that discuss the basic components of XSLT with examples. It is intended for beginners to help them understand the basic concepts of XSLT. Readers should have a basic knowledge of XML, HTML, and JavaScript before working through the tutorial. The tutorial is copyrighted and readers are prohibited from reusing or redistributing its content without permission.
XQuery is compliant with XPath and uses XPath expressions to restrict searches on XML collections. The document provides an XML collection of books and demonstrates three versions of an XQuery statement that returns the titles of books with a price greater than 30. Each version returns the same two book titles, but uses a different method to filter the books by price.
PostgreSQL is an open source relational database management system. It has over 15 years of active development and supports most operating systems. The tutorial provides instructions on installing PostgreSQL on Linux, Windows, and Mac operating systems. It also gives an overview of PostgreSQL's features and procedural language support.
PostgreSQL is an open-source relational database management system that runs on Linux, Unix, Windows and Mac OS. It supports SQL queries, transactions, foreign keys, triggers and views. To install PostgreSQL, download the installer package for your platform and run through the installation process, which sets up the database files and creates a default database and user account. The psql command-line tool can then be used to interact with and administer the PostgreSQL database using SQL commands.
This document provides an introduction and overview of the Perl programming language. It discusses Perl's syntax, variables, data types, control structures, file input/output, regular expressions, modules, and other key features. The document is intended to help transition unique NASA data and research technologies to operations using the Perl language.
This document is a 241-page tutorial on the Perl 5 programming language. It was written by Chan Bernard Ki Hong and published in 2003 under a Creative Commons license. The document provides an introduction to Perl and teaches the fundamentals of Perl programming, including data structures, operators, conditionals, loops, subroutines, references and more. It aims to help readers learn Perl and further improve the quality of the tutorial through reader feedback.
This document provides an introduction and overview of PHP 7. It discusses new features of PHP 7 such as improved performance (being twice as fast as PHP 5), lower memory consumption, scalar type declarations, consistent 64-bit support, improved exception hierarchy, addition of new secure random number generator API, and removal of deprecated extensions and SAPIs. It also provides information on setting up the PHP 7 environment on Linux/Unix, Mac OS X, and Windows platforms. It includes steps to install PHP, Apache web server, and configure the php.ini file. Code examples are provided to demonstrate new features like scalar type declarations and return type declarations.
MongoDB is an open-source document database that provides high performance and scalability. It uses collections and documents where collections are groups of documents and documents are sets of key-value pairs that can have different fields. MongoDB has databases which contain collections and each database gets its own set of files.
- The document is an Apache Maven tutorial that introduces Maven, a software project management and comprehension tool based on the concept of a project object model (POM).
- It discusses setting up the Maven environment, the Maven POM file, Maven build lifecycles including clean, build, and site, build profiles, repositories, plugins, and examples of using Maven to create, build, test, document, and deploy Java projects.
- The tutorial is intended for beginners to help them understand basic Maven functionality and use Maven for enterprise Java projects after completing it.
This document provides an introduction to Apache Mahout, including:
- Apache Mahout is an open source machine learning library that implements algorithms like recommendation, classification, and clustering on large datasets using Hadoop.
- It explains how to set up the environment for Mahout by installing Java, Hadoop, and Mahout. Key configuration files for Hadoop like core-site.xml, hdfs-site.xml, and yarn-site.xml are also discussed.
- Popular machine learning techniques like recommendation, classification, and clustering are briefly introduced in the context of how Mahout implements them on large datasets.
An embedded system is a microcontroller-based computer system designed to perform specific tasks. It can be an independent system or part of a larger system. This tutorial explains the steps to design and use an embedded system and focuses on the 8051 microcontroller. It covers topics like processors, architecture, tools, peripherals, I/O programming, assembly language and more to help students learn embedded systems and 8051 microcontrollers.
This document provides an overview and introduction to data structures and algorithms. It discusses the need for data structures to efficiently organize and store data as applications and data grow increasingly large and complex. It also covers some basic terminology used in data structures and algorithms. The document then discusses setting up both an online and local environment for writing and executing code in C programming language to work through examples.
This document provides a summary of the C Standard Library reference manual. It covers 15 key headers - <assert.h>, <ctype.h>, <errno.h>, <float.h>, <limits.h>, <locale.h>, <math.h>, <setjmp.h>, <signal.h>, <stdarg.h>, <stddef.h>, <stdio.h>, <stdlib.h>, <string.h>, and <time.h>. For each header, it lists the main library macros and functions, and provides brief descriptions and examples of how to use some of the more important functions like assert, various character checking functions, mathematical functions, memory allocation functions, and file I/
The document discusses the basic structure of a C program. It provides a simple "Hello World" program as an example. The program includes preprocessor commands, functions, variables, statements and expressions, and comments. It also describes how to save the code in a file, compile it using gcc, and execute the resulting program.
Embedded machine learning-based road conditions and driving behavior monitoringIJECEIAES
Car accident rates have increased in recent years, resulting in losses in human lives, properties, and other financial costs. An embedded machine learning-based system is developed to address this critical issue. The system can monitor road conditions, detect driving patterns, and identify aggressive driving behaviors. The system is based on neural networks trained on a comprehensive dataset of driving events, driving styles, and road conditions. The system effectively detects potential risks and helps mitigate the frequency and impact of accidents. The primary goal is to ensure the safety of drivers and vehicles. Collecting data involved gathering information on three key road events: normal street and normal drive, speed bumps, circular yellow speed bumps, and three aggressive driving actions: sudden start, sudden stop, and sudden entry. The gathered data is processed and analyzed using a machine learning system designed for limited power and memory devices. The developed system resulted in 91.9% accuracy, 93.6% precision, and 92% recall. The achieved inference time on an Arduino Nano 33 BLE Sense with a 32-bit CPU running at 64 MHz is 34 ms and requires 2.6 kB peak RAM and 139.9 kB program flash memory, making it suitable for resource-constrained embedded systems.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
Software Engineering and Project Management - Introduction, Modeling Concepts...Prakhyath Rai
Introduction, Modeling Concepts and Class Modeling: What is Object orientation? What is OO development? OO Themes; Evidence for usefulness of OO development; OO modeling history. Modeling
as Design technique: Modeling, abstraction, The Three models. Class Modeling: Object and Class Concept, Link and associations concepts, Generalization and Inheritance, A sample class model, Navigation of class models, and UML diagrams
Building the Analysis Models: Requirement Analysis, Analysis Model Approaches, Data modeling Concepts, Object Oriented Analysis, Scenario-Based Modeling, Flow-Oriented Modeling, class Based Modeling, Creating a Behavioral Model.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
3. TUTORIALS POINT
Simply Easy Learning
ABOUT THE TUTORIAL
iBATIS Tutorial
iBATIS is a persistence framework which automates the mapping between SQL databases and objects in
Java, .NET, and Ruby on Rails. iBATIS makes it easier to build better database oriented application more
quickly and with less code.
Audience
This tutorial is designed for Java programmers with a need to understand the iBATIS framework in detail
along with its architecture and actual usage. This tutorial will bring you at intermediate level of expertise
from where you can take yourself at higher level of expertise.
Prerequisites
Before proceeding with this tutorial you should have a good understanding of Java programming
language. Because you are going to deal with SQL mapping, so it is required that you have good
understanding on SQL and Database concepts.
Copyright & Disclaimer Notice
All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from
tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form
without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws.
This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the
accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site
or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com
5. TUTORIALS POINT
Simply Easy Learning
iBATIS Stored Procedures ....................................................... 28
Employee POJO Class:............................................................................29
Employee.xml File:...................................................................................29
IbatisSP.java File: ....................................................................................30
Compilation and Run:...............................................................................31
iBATIS Dynamic SQL............................................................... 32
Example: Dynamic SQL ...........................................................................33
Employee POJO Class:............................................................................33
Employee.xml File:...................................................................................34
IbatisReadDy.java File: ............................................................................34
Compilation and Run:...............................................................................35
iBATIS OGNL Expressions ......................................................................35
The if Statement:......................................................................................36
The choose, when, otherwise Statement: ................................................36
The where Statement:..............................................................................37
The foreach Statement:............................................................................37
iBATIS Debugging.................................................................... 38
Debugging with Log4J:.............................................................................38
iBATIS Debugging Example:....................................................................39
Compilation and Run:...............................................................................40
Debug Methods:.......................................................................................40
iBATIS Hibernate...................................................................... 41
iBATOR Introduction ................................................................ 43
Download iBATOR: ..................................................................................43
Generating Configuration File: .................................................................43
Step 1:......................................................................................................43
Step 2:......................................................................................................44
Step 3:......................................................................................................44
Tasks After Running Abator: ....................................................................44
Updating the SqlMapConfig.xml File: .......................................................44
Updating the dao.xml File:........................................................................45
6. TUTORIALS POINT
Simply Easy Learning
iBATIS Overview
IBATIS is a persistence framework which automates the mapping between SQL databases and objects in
Java, .NET, and Ruby on Rails. The mappings are decoupled from the application logic by packaging the SQL
statements in XML configuration files.
iBATIS is a lightweight framework and persistence API good for persisting POJOs( Plain Old Java Objects).
iBATIS is what is known as a data mapper and takes care of mapping the parameters and results between the
class properties and the columns of the database table.
A significant difference between iBATIS and other persistence frameworks such as Hibernate is that iBATIS
emphasizes use of SQL, while other frameworks typically use a custom query language such has the Hibernate
Query Language (HQL) or Enterprise JavaBeans Query Language (EJB QL).
iBATIS Design Philosophies:
iBATIS comes with the following design philosophies:
Simplicity: iBATIS is widely regarded as being one of the simplest persistence frameworks available today.
Fast Development: iBATIS's philosophy is to do all it can to facilitate hyper-fast development.
Portability: iBATIS can be implemented for nearly any language or platform like Java, Ruby, and C# for
Microsoft .NET.
Independent Interfaces: iBATIS provides database-independent interfaces and APIs that help the rest of
the application remain independent of any persistence-related resources,
Open source: iBATIS is free and an open source software.
Advantages of IBATIS
Here are few advantages of using IBATIS:
Suppports Stored procedures: iBATIS encapsulates SQL in the form of stored procedures so that
business logic is kept out of the database, and the application is easier to deploy and test, and is more
portable.
Supports Inline SQL: No precompiler is needed, and you have full access to all of the features of SQL.
Supports Dynamic SQL: iBATIS provides features for dynamically building SQL queries based on
parameters.
CHAPTER
1
7. TUTORIALS POINT
Simply Easy Learning
Supports O/RM: iBATIS supports many of the same features as an O/RM tool, such as lazy loading, join
fetching, caching, runtime code generation, and inheritance
Pre-Requisite:
Before you proceed, you make sure that you understand the basics of procedural and object-oriented
programming: control structures, data structures and variables, classes, objects etc.
iBATIS makes use of JAVA programming language while developing database oriented application.
To understand JAVA in detail you can go through our JAVA Tutorial.
8. TUTORIALS POINT
Simply Easy Learning
iBATIS Environment
Before you start with actual development with iBATIS, you would have to setup your envrionment properly.
This tutorial would guide you with few steps to achieve a working environment.
iBATIS Installation:
Here are the simple steps you would need to carry out to install iBATIS on your Linux machine:
Download latest version of iBATIS from Download iBATIS.
Unzip the downloaded file to extract .jar file from the bundle and keep it in appropriate lib directory.
Set PATH and CLASSPATH variables at the extracted .jar file(s) appropriately.
Here are the steps I carried out on my linux machine after downloading iBATIS binary file:
$ unzip ibatis-2.3.4.726.zip
inflating: META-INF/MANIFEST.MF
creating: doc/
creating: lib/
creating: simple_example/
creating: simple_example/com/
creating: simple_example/com/mydomain/
creating: simple_example/com/mydomain/data/
creating: simple_example/com/mydomain/domain/
creating: src/
inflating: doc/dev-javadoc.zip
inflating: doc/user-javadoc.zip
inflating: jar-dependencies.txt
inflating: lib/ibatis-2.3.4.726.jar
inflating: license.txt
inflating: notice.txt
inflating: release.txt
$pwd
/var/home/ibatis
$set PATH=$PATH:/var/home/ibatis/
$set CLASSPATH=$CLASSPATH:/var/home/ibatis
/lib/ibatis-2.3.4.726.jar
CHAPTER
2
9. TUTORIALS POINT
Simply Easy Learning
Database Setup:
Create EMPLOYEE table in any MySQL database using the following syntax:
mysql> CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
Create SqlMapConfig.xml
Consider the following:
We are going to use JDBC to access the database testdb.
JDBC driver for MySQL is "com.mysql.jdbc.Driver".
Connection URL is "jdbc:mysql://localhost:3306/testdb".
We would use username and password is "root" and "root".
Our sql statement mappings for all the operations would be described in "Employee.xml".
Based on the above assumption we have to create an XML configuration file with nameSqlMapConfig.xml with
the following content. This is where you need to provide all configurations required for iBatis:
It is important that both the files SqlMapConfig.xml and Employee.xml should be present in the class path. For now
we would keep Employee.xml file empty and we would conver its content in subsequent chapters.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings useStatementNamespaces="true"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver"
value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://localhost:3306/testdb"/>
<property name="JDBC.Username" value="root"/>
<property name="JDBC.Password" value="root"/>
</dataSource>
</transactionManager>
<sqlMap resource="Employee.xml"/>
</sqlMapConfig>
There are other optional properties which you can set using SqlMapConfig.xml file:
<property name="JDBC.AutoCommit" value="true"/>
<property name="Pool.MaximumActiveConnections" value="10"/>
11. TUTORIALS POINT
Simply Easy Learning
iBATIS Create Operation
To perform any CRUD ( Create, Write, Update and Delete) operation using iBATIS, you would need to
create a POJOs (Plain Old Java Objects) class corresponding to the table. This class describes the objects that will
"model" database table rows.
The POJO class would have implementation for all the methods required to perform desired operations.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
Employee POJO Class:
We would create Employee class in Employee.java file as follows:
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
}
} /* End of Employee */
You can define methods to set individual fields in the table. Next chapter would show you how to get value of
individual fields.
CHAPTER
3
12. TUTORIALS POINT
Simply Easy Learning
Employee.xml File:
To define SQL mapping statement using iBATIS, we would use <insert> tag and inside this tag definition we would
define an "id" which will be used in IbatisInsert.java file for executing SQL INSERT query on database.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<insert id="insert" parameterClass="Employee">
insert into EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
</sqlMap>
Here parameterClass: could take a value as string, int, float, double or any class object based on requirement. In
this example we would pass Employee object as a parameter while calling insertmethod of SqlMap class.
If your database table uses an IDENTITY, AUTO_INCREMENT, or SERIAL column or you have defined a
SEQUENCE/GENERATOR, you can use the <selectKey> element in an <insert> statement to use or return that
database-generated value.
IbatisInsert.java File:
This file would have application level logic to insert records in the Employee table:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisInsert{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would insert one record in Employee table. */
System.out.println("Going to insert record.....");
Employee em = new Employee("Zara", "Ali", 5000);
smc.insert("Employee.insert", em);
System.out.println("Record Inserted Successfully ");
}
}
13. TUTORIALS POINT
Simply Easy Learning
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisInsert.java as shown above and compile it.
Execute IbatisInsert binary to run the program.
You would get following result, and a record would be created in EMPLOYEE table.
$java IbatisInsert
Going to insert record.....
Record Inserted Successfully
Go and check your EMPLOYEE table, it should have following result:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
+----+------------+-----------+--------+
1 row in set (0.00 sec)
14. TUTORIALS POINT
Simply Easy Learning
iBATIS Read Operation
Last chapter has shown how to perform CREATE operation on a table using iBATIS. This chapter would
show you how to read a table using iBATIS.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
This table is having only one record as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
+----+------------+-----------+--------+
1 row in set (0.00 sec)
Employee POJO Class:
To perform read operation we would modify Employee class in Employee.java file as follows:
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
CHAPTER
4
15. TUTORIALS POINT
Simply Easy Learning
}
/* Here are the method definitions */
public int getId() {
return id;
}
public String getFirstName() {
return first_name;
}
public String getLastName() {
return last_name;
}
public int getSalary() {
return salary;
}
} /* End of Employee */
Employee.xml File:
To define SQL mapping statement using iBATIS, we would add <select> tag in Employee.xml file and inside this
tag definition we would define an "id" which will be used in IbatisRead.java file for executing SQL SELECT query
on database.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<insert id="insert" parameterClass="Employee">
INSERT INTO EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
<select id="getAll" resultClass="Employee">
SELECT * FROM EMPLOYEE
</select>
</sqlMap>
Here we did not use WHERE clause with SQL SELECT statement. Subsequent chapter would demonstrate how
you can use WHERE clause with SELECT statement and how you can pass values to that WHERE clause.
IbatisRead.java File:
This file would have application level logic to read records from the Employee table:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisRead{
public static void main(String[] args)
16. TUTORIALS POINT
Simply Easy Learning
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would read all records from the Employee table. */
System.out.println("Going to read records.....");
List <Employee> ems = (List<Employee>)
smc.queryForList("Employee.getAll", null);
Employee em = null;
for (Employee e : ems) {
System.out.print(" " + e.getId());
System.out.print(" " + e.getFirstName());
System.out.print(" " + e.getLastName());
System.out.print(" " + e.getSalary());
em = e;
System.out.println("");
}
System.out.println("Records Read Successfully ");
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisRead.java as shown above and compile it.
Execute IbatisRead binary to run the program.
You would get following result, and a record would be read from the EMPLOYEE table.
Going to read records.....
1 Zara Ali 5000
Record Reads Successfully
17. TUTORIALS POINT
Simply Easy Learning
iBATIS Update Operation
Last chapter has shown how to perform READ operation on a table using iBATIS. This chapter would
show you how you can update records in a table using iBATIS.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
This table is having only one record as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
+----+------------+-----------+--------+
1 row in set (0.00 sec)
Employee POJO Class:
To perform udpate operation you would need to modify Employee.java file as follows:
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
CHAPTER
5
18. TUTORIALS POINT
Simply Easy Learning
}
/* Here are the required method definitions */
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return first_name;
}
public void setFirstName(String fname) {
this.first_name = fname;
}
public String getLastName() {
return last_name;
}
public void setlastName(String lname) {
this.last_name = lname;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
} /* End of Employee */
Employee.xml File:
To define SQL mapping statement using iBATIS, we would add <update> tag in Employee.xml file and inside this
tag definition we would define an "id" which will be used in IbatisUpdate.java file for executing SQL UPDATE query
on database.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<insert id="insert" parameterClass="Employee">
INSERT INTO EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
<select id="getAll" resultClass="Employee">
SELECT * FROM EMPLOYEE
</select>
<update id="update" parameterClass="Employee">
UPDATE EMPLOYEE
SET first_name = #first_name#
WHERE id = #id#
19. TUTORIALS POINT
Simply Easy Learning
</update>
</sqlMap>
IbatisUpdate.java File:
This file would have application level logic to update records into the Employee table:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisUpdate{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would update one record in Employee table. */
System.out.println("Going to update record.....");
Employee rec = new Employee();
rec.setId(1);
rec.setFirstName( "Roma");
smc.update("Employee.update", rec );
System.out.println("Record updated Successfully ");
System.out.println("Going to read records.....");
List <Employee> ems = (List<Employee>)
smc.queryForList("Employee.getAll", null);
Employee em = null;
for (Employee e : ems) {
System.out.print(" " + e.getId());
System.out.print(" " + e.getFirstName());
System.out.print(" " + e.getLastName());
System.out.print(" " + e.getSalary());
em = e;
System.out.println("");
}
System.out.println("Records Read Successfully ");
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisUpdate.java as shown above and compile it.
20. TUTORIALS POINT
Simply Easy Learning
Execute IbatisUpdate binary to run the program.
You would get following result, and a record would be updated in EMPLOYEE table and later same record would
be read from the EMPLOYEE table.
Going to update record.....
Record updated Successfully
Going to read records.....
1 Roma Ali 5000
Records Read Successfully
21. TUTORIALS POINT
Simply Easy Learning
Ibatis Delete Operation
This chapter would teach you how you can delete records from a table using iBATIS.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
Assume this table is having two records as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
| 2 | Roma | Ali | 3000 |
+----+------------+-----------+--------+
2 row in set (0.00 sec)
Employee POJO Class:
To perform delete operation you do need to modify Employee.java file. So let us keep it as it is in last chapter.
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
CHAPTER
6
22. TUTORIALS POINT
Simply Easy Learning
}
/* Here are the required method definitions */
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return first_name;
}
public void setFirstName(String fname) {
this.first_name = fname;
}
public String getLastName() {
return last_name;
}
public void setlastName(String lname) {
this.last_name = lname;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
} /* End of Employee */
Employee.xml File:
To define SQL mapping statement using iBATIS, we would add <delete> tag in Employee.xml file and inside this
tag definition we would define an "id" which will be used in IbatisDelete.java file for executing SQL DELETE query
on database.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<insert id="insert" parameterClass="Employee">
INSERT INTO EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
<select id="getAll" resultClass="Employee">
SELECT * FROM EMPLOYEE
</select>
<update id="update" parameterClass="Employee">
UPDATE EMPLOYEE
SET first_name = #first_name#
WHERE id = #id#
23. TUTORIALS POINT
Simply Easy Learning
</update>
<delete id="delete" parameterClass="int">
DELETE FROM EMPLOYEE
WHERE id = #id#
</delete>
</sqlMap>
IbatisDelete.java File:
This file would have application level logic to delete records from the Employee table:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisDelete{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would delete one record in Employee table. */
System.out.println("Going to delete record.....");
int id = 1;
smc.delete("Employee.delete", id );
System.out.println("Record deleted Successfully ");
System.out.println("Going to read records.....");
List <Employee> ems = (List<Employee>)
smc.queryForList("Employee.getAll", null);
Employee em = null;
for (Employee e : ems) {
System.out.print(" " + e.getId());
System.out.print(" " + e.getFirstName());
System.out.print(" " + e.getLastName());
System.out.print(" " + e.getSalary());
em = e;
System.out.println("");
}
System.out.println("Records Read Successfully ");
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
24. TUTORIALS POINT
Simply Easy Learning
Create Employee.java as shown above and compile it.
Create IbatisDelete.java as shown above and compile it.
Execute IbatisDelete binary to run the program.
You would get following result, and a record with ID = 1, would be deleted in EMPLOYEE table and rest of the
records would be read from the EMPLOYEE table.
Going to delete record.....
Record deleted Successfully
Going to read records.....
2 Roma Ali 3000
Records Read Successfully
25. TUTORIALS POINT
Simply Easy Learning
iBATIS Result Maps
The resultMap element is the most important and powerful element in iBATIS. You can reduce upto 90%
JDBC coding by using iBATIS ResultMap and in some cases allows you to do things that JDBC does not even
support.
The design of the ResultMaps is such that simple statements don't require explicit result mappings at all, and more
complex statements require no more than is absolutely necessary to describe the relationships.
This chapter would give you just a simple introduction of iBATIS ResultMap.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
This table is having two records as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
| 2 | Roma | Ali | 3000 |
+----+------------+-----------+--------+
2 row in set (0.00 sec)
Employee POJO Class:
To use iBATIS ResultMap, you do need to modify Employee.java file. So let us keep it as it is in last chapter.
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
CHAPTER
7
26. TUTORIALS POINT
Simply Easy Learning
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
}
/* Here are the required method definitions */
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return first_name;
}
public void setFirstName(String fname) {
this.first_name = fname;
}
public String getLastName() {
return last_name;
}
public void setlastName(String lname) {
this.last_name = lname;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
} /* End of Employee */
Employee.xml File:
Here we would modify Employee.xml file to introduce <resultMap></resultMap> tag. This tag would have an id
which is required to run this resultMap in our <select> tag's resultMap attribute.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<!-- Perform Insert Operation -->
<insert id="insert" parameterClass="Employee">
INSERT INTO EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
27. TUTORIALS POINT
Simply Easy Learning
<!-- Perform Read Operation -->
<select id="getAll" resultClass="Employee">
SELECT * FROM EMPLOYEE
</select>
<!-- Perform Update Operation -->
<update id="update" parameterClass="Employee">
UPDATE EMPLOYEE
SET first_name = #first_name#
WHERE id = #id#
</update>
<!-- Perform Delete Operation -->
<delete id="delete" parameterClass="int">
DELETE FROM EMPLOYEE
WHERE id = #id#
</delete>
<!-- Using ResultMap -->
<resultMap id="result" class="Employee">
<result property="id" column="id"/>
<result property="first_name" column="first_name"/>
<result property="last_name" column="last_name"/>
<result property="salary" column="salary"/>
</resultMap>
<select id="useResultMap" resultMap="result">
SELECT * FROM EMPLOYEE
WHERE id=#id#
</select>
</sqlMap>
IbatisResultMap.java File:
This file would have application level logic to read records from the Employee table using ResultMap:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisResultMap{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
int id = 1;
System.out.println("Going to read record.....");
Employee e = (Employee)smc.queryForObject
("Employee.useResultMap", id);
System.out.println("ID: " + e.getId());
System.out.println("First Name: " + e.getFirstName());
System.out.println("Last Name: " + e.getLastName());
System.out.println("Salary: " + e.getSalary());
System.out.println("Record read Successfully ");
28. TUTORIALS POINT
Simply Easy Learning
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisResultMap.java as shown above and compile it.
Execute IbatisResultMap binary to run the program.
You would get following result which is a read operation on the EMPLOYEE table.
Going to read record.....
ID: 1
First Name: Zara
Last Name: Ali
Salary: 5000
Record read Successfully
29. TUTORIALS POINT
Simply Easy Learning
iBATIS Stored Procedures
This is very much possible to call a stored procedure using iBATIS configuration. To understand this
chapter, first you need to understand how we create a stored procedure in MySQL.
Before procedding for this chapter you can go through MySQL Stored Procedure.
We have following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
Let us have following stored procedure created in MySQL database.
DELIMITER $$
DROP PROCEDURE IF EXISTS `testdb`.`getEmp` $$
CREATE PROCEDURE `testdb`.`getEmp`
(IN empid INT)
BEGIN
SELECT * FROM EMPLOYEE
WHERE ID = empid;
END $$
DELIMITER;
Consider EMPLOYEE table is having two records as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
| 2 | Roma | Ali | 3000 |
+----+------------+-----------+--------+
2 row in set (0.00 sec)
CHAPTER
8
30. TUTORIALS POINT
Simply Easy Learning
Employee POJO Class:
To use stored procedure, you do need to modify Employee.java file. So let us keep it as it is in last chapter.
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
}
/* Here are the required method definitions */
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return first_name;
}
public void setFirstName(String fname) {
this.first_name = fname;
}
public String getLastName() {
return last_name;
}
public void setlastName(String lname) {
this.last_name = lname;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
} /* End of Employee */
Employee.xml File:
Here we would modify Employee.xml file to introduce <procedure></procedure> and
<parameterMap></parameterMap> tags. Here <procedure></procedure> tag would have an id which we would
use in our application to call the stored procedure.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
31. TUTORIALS POINT
Simply Easy Learning
<!-- Perform Insert Operation -->
<insert id="insert" parameterClass="Employee">
INSERT INTO EMPLOYEE(first_name, last_name, salary)
values (#first_name#, #last_name#, #salary#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id
</selectKey>
</insert>
<!-- Perform Read Operation -->
<select id="getAll" resultClass="Employee">
SELECT * FROM EMPLOYEE
</select>
<!-- Perform Update Operation -->
<update id="update" parameterClass="Employee">
UPDATE EMPLOYEE
SET first_name = #first_name#
WHERE id = #id#
</update>
<!-- Perform Delete Operation -->
<delete id="delete" parameterClass="int">
DELETE FROM EMPLOYEE
WHERE id = #id#
</delete>
<!-- To call stored procedure. -->
<procedure id="getEmpInfo" resultClass="Employee"
parameterMap="getEmpInfoCall">
{ call getEmp( #acctID# ) }
</procedure>
<parameterMap id="getEmpInfoCall" class="map">
<parameter property="acctID" jdbcType="INT"
javaType="java.lang.Integer" mode="IN"/>
</parameterMap>
</sqlMap>
IbatisSP.java File:
This file would have application level logic to read name of the employee from the Employee table using
ResultMap:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisSP{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
32. TUTORIALS POINT
Simply Easy Learning
int id = 1;
System.out.println("Going to read employee name.....");
Employee e = (Employee)smc.queryForObject
("Employee.getEmpInfo", id);
System.out.println("First Name: " + e.getFirstName());
System.out.println("Record name Successfully ");
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH
and CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisSP.java as shown above and compile it.
Execute IbatisSP binary to run the program.
You would get following result:
Going to read record.....
ID: 1
First Name: Zara
Last Name: Ali
Salary: 5000
Record read Successfully
33. TUTORIALS POINT
Simply Easy Learning
iBATIS Dynamic SQL
Using dynamic queries is a very powerful feature of iBatis. Sometime you have changing WHERE clause
criterion based on your parameter object's state. In such situation iBATIS provides a set of dynamic SQL tags that
can be used within mapped statements to enhance the reusability and flexibility of the SQL.
All the logic is put in .XML file using some additional tags. Following is an example where SELECT statement
would work in two ways:
If you would pass an ID then it would return all the records corresponding to that ID,
otherwise it would return all the records where employee ID is set to NULL.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<select id="findByID" resultClass="Employee">
SELECT * FROM EMPLOYEE
<dynamic prepend="WHERE ">
<isNull property="id">
id IS NULL
</isNull>
<isNotNull property="id">
id = #id#
</isNotNull>
</dynamic>
</select>
</sqlMap>
You can check condition using <isNotEmpty> tag as follows. Here condition would be added only when passed
property is not empty.
..................
<select id="findByID" resultClass="Employee">
SELECT * FROM EMPLOYEE
<dynamic prepend="WHERE ">
<isNotEmpty property="id">
id = #id#
</isNotEmpty>
</dynamic>
CHAPTER
9
34. TUTORIALS POINT
Simply Easy Learning
</select>
..................
If you want a query where we can select on id and/or first name of an Employee. Here would be your SELECT
statement:
..................
<select id="findByID" resultClass="Employee">
SELECT * FROM EMPLOYEE
<dynamic prepend="WHERE ">
<isNotEmpty prepend="AND" property="id">
id = #id#
</isNotEmpty>
<isNotEmpty prepend="OR" property="first_name">
first_name = #first_name#
</isNotEmpty>
</dynamic>
</select>
..................
Example: Dynamic SQL
Following example would show how you can write SELECT statement with dynamic SQL. Consider, we have
following EMPLOYEE table in MySQL:
CREATE TABLE EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
This table is having only one record as follows:
mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 1 | Zara | Ali | 5000 |
| 2 | Roma | Ali | 3000 |
| 3 | Noha | Ali | 7000 |
+----+------------+-----------+--------+
3 row in set (0.00 sec)
Employee POJO Class:
To perform read operation, let us have Employee class in Employee.java file as follows:
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
35. TUTORIALS POINT
Simply Easy Learning
this.first_name = fname;
this.last_name = lname;
this.salary = salary;
}
/* Here are the method definitions */
public int getId() {
return id;
}
public String getFirstName() {
return first_name;
}
public String getLastName() {
return last_name;
}
public int getSalary() {
return salary;
}
} /* End of Employee */
Employee.xml File:
To define SQL mapping statement using iBATIS, we would add following modified <select> tag in Employee.xml
file and inside this tag definition we would define an "id" which will be used in IbatisReadDy.java file for executing
Dynamic SQL SELECT query on database.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Employee">
<select id="findByID" resultClass="Employee">
SELECT * FROM EMPLOYEE
<dynamic prepend="WHERE ">
<isNotNull property="id">
id = #id#
</isNotNull>
</dynamic>
</select>
</sqlMap>
Above SELECT statement would work in two ways (i) If you would pass an ID then it would return records
corresponding to that ID (ii) otherwise it would return all the records.
IbatisReadDy.java File:
This file would have application level logic to read conditional records from the Employee table:
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisReadDy{
public static void main(String[] args)
throws IOException,SQLException{
36. TUTORIALS POINT
Simply Easy Learning
Reader rd=Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc=SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would read all records from the Employee table.*/
System.out.println("Going to read records.....");
Employee rec = new Employee();
rec.setId(1);
List <Employee> ems = (List<Employee>)
smc.queryForList("Employee.findByID", rec);
Employee em = null;
for (Employee e : ems) {
System.out.print(" " + e.getId());
System.out.print(" " + e.getFirstName());
System.out.print(" " + e.getLastName());
System.out.print(" " + e.getSalary());
em = e;
System.out.println("");
}
System.out.println("Records Read Successfully ");
}
}
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisReadDy.java as shown above and compile it.
Execute IbatisReadDy binary to run the program.
You would get following result, and a record would be read from the EMPLOYEE table.
Going to read records.....
1 Zara Ali 5000
Record Reads Successfully
Try above example by passing null as smc.queryForList("Employee.findByID", null).
iBATIS OGNL Expressions
iBATIS provides powerful OGNL based expressions to eliminate most of the other elements.
if Statement
choose, when, otherwise Statement
where Statement
37. TUTORIALS POINT
Simply Easy Learning
foreach Statement
The if Statement:
The most common thing to do in dynamic SQL is conditionally include a part of a where clause. For example:
<select id="findActiveBlogWithTitleLike"
parameterType="Blog" resultType="Blog">
SELECT * FROM BLOG
WHERE state = 'ACTIVE.
<if test="title != null">
AND title like #{title}
</if>
</select>
This statement would provide an optional text search type of functionality. If you passed in no title, then all active
Blogs would be returned. But if you do pass in a title, it will look for a title with the given likecondition.
You can include multiple if conditions as follows:
The most common thing to do in dynamic SQL is conditionally include a part of a where clause. For example:
<select id="findActiveBlogWithTitleLike"
parameterType="Blog" resultType="Blog">
SELECT * FROM BLOG
WHERE state = 'ACTIVE.
<if test="title != null">
AND title like #{title}
</if>
<if test="author != null">
AND author like #{author}
</if>
</select>
The choose, when, otherwise Statement:
iBATIS offers a choose element which is similar to Java's switch statement. This helps choose only one case
among many options.
Following example would search only on title if one is provided, then only by author if one is provided. If neither is
provided, let's only return featured blogs:
<select id="findActiveBlogWithTitleLike"
parameterType="Blog" resultType="Blog">
SELECT * FROM BLOG
WHERE state = 'ACTIVE.
<choose>
<when test="title != null">
AND title like #{title}
</when>
<when test="author != null and author.name != null">
AND author like #{author}
</when>
<otherwise>
AND featured = 1
</otherwise>
</choose>
</select>
38. TUTORIALS POINT
Simply Easy Learning
The where Statement:
If we look previous examples, What happens if none of the conditions are met? You would end up with SQL that
looked like this:
SELECT * FROM BLOG
WHERE
This would fail, but iBATIS has a simple solution with one simple change, everything works fine:
<select id="findActiveBlogLike"
parameterType="Blog" resultType="Blog">
SELECT * FROM BLOG
<where>
<if test="state != null">
state = #{state}
</if>
<if test="title != null">
AND title like #{title}
</if>
<if test="author != null>
AND author like #{author}
</if>
</where>
</select>
The where element knows to only insert WHERE if there is any content returned by the containing tags.
Furthermore, if that content begins with AND or OR, it knows to strip it off.
The foreach Statement:
The foreach element is very powerful, and allows you to specify a collection, declare item and index variables that
can be used inside the body of the element.
It also allows you to specify opening and closing strings, and add a separator to place in between iterations. You
can build an IN condition as follows:
<select id="selectPostIn" resultType="domain.blog.Post">
SELECT *
FROM POST P
WHERE ID in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
39. TUTORIALS POINT
Simply Easy Learning
iBATIS Debugging
It is easy to debug your program while working with iBATIS. iBATIS has built-in logging support and it works
with the following logging libraries and searches for them in this order.
Jakarta Commons Logging (JCL).
Log4J
JDK logging
You can use any of the above listed libraries alongwith iBATIS.
Debugging with Log4J:
Assuming you are going to use Log4J, which is my favorite for logging. Before proceeding you need to cross check
following points:
The Log4J JAR file (log4j-{version}.jar) should be in the CLASSPATH.
You have log4j.properties available in the CLASSPATH.
Following is the of a log4j.properties file. Note that some of the lines are commented out. You can uncomment
them if you need additiona debugging information.
# Global logging configuration
log4j.rootLogger=ERROR, stdout
log4j.logger.com.ibatis=DEBUG
# shows SQL of prepared statements
#log4j.logger.java.sql.Connection=DEBUG
# shows parameters inserted into prepared statements
#log4j.logger.java.sql.PreparedStatement=DEBUG
# shows query results
#log4j.logger.java.sql.ResultSet=DEBUG
#log4j.logger.java.sql.Statement=DEBUG
CHAPTER
10
40. TUTORIALS POINT
Simply Easy Learning
# Console output
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
You can find complete documentation for Log4J from Apaches site: Log4J Documentation.
iBATIS Debugging Example:
The following Java class is a very simple example that initializes, and then uses, the Log4J logging library for Java
applications. We would use above mentioned property file which lies in CLASSPATH.
import org.apache.log4j.Logger;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisUpdate{
static Logger log = Logger.getLogger(
IbatisUpdate.class.getName());
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would insert one record in Employee table. */
log.info("Going to update record.....");
Employee rec = new Employee();
rec.setId(1);
rec.setFirstName( "Roma");
smc.update("Employee.update", rec );
log.info("Record updated Successfully ");
log.debug("Going to read records.....");
List <Employee> ems = (List<Employee>)
smc.queryForList("Employee.getAll", null);
Employee em = null;
for (Employee e : ems) {
System.out.print(" " + e.getId());
System.out.print(" " + e.getFirstName());
System.out.print(" " + e.getLastName());
System.out.print(" " + e.getSalary());
em = e;
System.out.println("");
}
log.debug("Records Read Successfully ");
}
}
41. TUTORIALS POINT
Simply Easy Learning
Compilation and Run:
Here are the steps to compile and run the above mentioned software. Make sure you have set PATH and
CLASSPATH appropriately before proceeding for the compilation and execution.
Create Employee.xml as shown above.
Create Employee.java as shown above and compile it.
Create IbatisUpdate.java as shown above and compile it.
Create log4j.properties as shown above.
Execute IbatisUpdate binary to run the program.
You would get following result, and a record would be updated in EMPLOYEE table and later same record would
be read from the EMPLOYEE table.
DEBUG [main] - Created connection 28405330.
DEBUG [main] - Returned connection 28405330 to pool.
DEBUG [main] - Checked out connection 28405330 from pool.
DEBUG [main] - Returned connection 28405330 to pool.
1 Roma Ali 5000
2 Zara Ali 5000
3 Zara Ali 5000
Debug Methods:
In the above example we used only info() method but you can use any of the following methods as per your
requirements:
public void trace(Object message);
public void debug(Object message);
public void info(Object message);
public void warn(Object message);
public void error(Object message);
public void fatal(Object message);
42. TUTORIALS POINT
Simply Easy Learning
iBATIS Hibernate
There are major differences between iBatis and Hibernate but both the solutions work well, given their
specific domain. Personally I would suggest you should use iBATIS if:
You want to create your own SQL's and are willing to maintain them.
Your environment is driven by relational data model.
You have to work existing and complex schema's.
And simply use Hibernate if:
Your environment is driven by object model and wants generates SQL automatically.
To count there are few differences:
iBATIS is:
o Simpler
o Faster development time
o Flixable
o Much smaller in package size
Hibernate:
o Generates SQL for you which means you don't spend time on SQL
o Provides much more advance cache
o Highly scalable
Other difference is that iBATIS makes use of SQL which could be database dependent where as Hibernate
makes use of HQL which is relatively independent of databases and it is easier to change db in Hibernate.
CHAPTER
11
43. TUTORIALS POINT
Simply Easy Learning
Hibernate maps your Java POJO objects to the Database tables where as iBatis maps the ResultSet from JDBC
API to your POJO Objets.
If you are using stored procedures, well you can do it in Hibernate but it is little difficult in comparision of iBATIS.
As an alternative solution iBATIS maps results sets to objects, so no need to care about table structures. This
works very well for stored procedures, works very well for reporting applications, etc
Finally, Hibernate and iBATIS both are open source Object Relational Mapping(ORM) tools available in the
industry. Use of each of these tools depends on the context you are using them. Hibernate and iBatis both also
have good support from SPRING framework so it should not be a problem to chose one of them.
44. TUTORIALS POINT
Simply Easy Learning
iBATOR Introduction
IBATOR is a code generator for iBATIS. iBATOR introspects one or more database tables and will generate
iBATIS artifacts that can be used to access the table(s).
Later you can write your custom SQL code or stored procedure to meet yoru requirements. iBATOR generates
following artifacts:
SqlMap XML Files
Java Classes to match the primary key and fields of the table(s)
DAO Classes that use the above objects (optional)
iBATOR can run as a standalone JAR file, or as an Ant task, or as an Eclipse plugin. This tutorial would teach you
simplest way of generating iBATIS configuration files form command line.
Download iBATOR:
Download the standalone JAR if you are using an IDE other than Eclipse. The standalone JAR includes an Ant
task to run iBATOR, or you can run iBATOR from the command line of from Java code.
You can download zip file from Download iBATOR.
You can check online documentation: iBATOR Documentation.
Generating Configuration File:
To get up and running quickly with Abator, follow these steps:
Step 1:
Create and fill out a configuration file ibatorConfig.xml appropriately. At a minimum, you must specify:
A <jdbcConnection> element to specify how to connect to the target database.
A <javaModelGenerator> element to specify target package and target project for generated Java model
objects
A <sqlMapGenerator> element to specify target package and target project for generated SQL map files.
CHAPTER
12
45. TUTORIALS POINT
Simply Easy Learning
A <daoGenerator> element to specify target package and target project for generated DAO interfaces and
classes (you may omit the <daoGenerator> element if you don't wish to generate DAOs).
At least one database <table> element
NOTE: See the XML Configuration File Reference page for an example of an Abator configuration file.
Step 2:
Save the file in some convenient location for example at: tempibatorConfig.xml).
Step 3:
Now run Abator from the command line with a command line as follows:
java -jar abator.jar -configfile tempabatorConfig.xml -overwrite
This will tell Abator to run using your configuration file. It will also tell Abator to overwrite any existing Java files with
the same name. If you want to save any existing Java files, then omit the -overwriteparameter.
If there is a conflict, Abator will save the newly generated file with a unique name.
After running Abator, you will need to create or modify the standard iBATIS configuration files to make use of your
newly generated code. This is explained in next section.
Tasks After Running Abator:
After you run Abator, you will need to create or modify other iBATIS configuration artifacts. The main tasks are as
follows:
Create or Modify the SqlMapConfig.xml file.
Create or modify the dao.xml file (only if using the iBATIS DAO Framework).
Each task is described in detail below:
Updating the SqlMapConfig.xml File:
iBATIS uses an XML file, commonly named SqlMapConfig.xml, to specify information for a database connection, a
transaction management scheme, and SQL map XML files that will be used in an iBATIS session.
Abator cannot create this file for you because Abator knows nothing about your execution environment. However,
some of the items in this file relate directly to Abator generated items.
Abator specific needs in the configuration file are as follows:
Statement namespaces must be enabled.
Abator generated SQL Map XML files must be listed .
For example, suppose that Abator has generated an SQL Map XML file called MyTable_SqlMap.xml, and that the
file has been placed in the test.xml package of your project. The SqlMapConfig.xml file should have these entries:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
46. TUTORIALS POINT
Simply Easy Learning
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- Statement namespaces are required for Abator -->
<settings useStatementNamespaces="true" />
<!-- Setup the transaction manager and data source that are
appropriate for your environment
-->
<transactionManager type="...">
<dataSource type="...">
</dataSource>
</transactionManager>
<!-- SQL Map XML files should be listed here -->
<sqlMap resource="test/xml/MyTable_SqlMap.xml" />
</sqlMapConfig>
If there is more than one SQL Map XML file (as is quite common), then the files can be listed in any order with
repeated <sqlMap> elements after the <transactionManager> element.
Updating the dao.xml File:
The iBATIS DAO framework is configured by an xml file commonly called dao.xml.
The iBATIS DAO framework uses this file to control the database connection information for DAOs, and also to list
the DAO implementation classes and DAO interfaces.
In this file you should specify the path to your SqlMapConfig.xml file, and all the Abator generated DAO interfaces
and implementation classes.
For example, suppose that Abator has generated a DAO interface called MyTableDAO and a implementation class
called MyTableDAOImpl, and that the files have been placed in the test.dao package of your project.
The dao.xml file should have these entries:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE daoConfig
PUBLIC "-//ibatis.apache.org//DTD DAO Configuration 2.0//EN"
"http://ibatis.apache.org/dtd/dao-2.dtd">
<daoConfig>
<context>
<transactionManager type="SQLMAP">
<property name="SqlMapConfigResource"
value="test/SqlMapConfig.xml"/>
</transactionManager>
<!-- DAO interfaces and implementations
should be listed here -->
<dao interface="test.dao.MyTableDAO"
implementation="test.dao.MyTableDAOImpl" />
</context>
</daoConfig>
NOTE: This step is only required if you generated DAOs for the iBATIS DAO framework.