YAGDAO 0.3.1 Yet Another DAO Hibernate Guide. yagdao   Mert Can Akkan.

Slides:



Advertisements
Similar presentations
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
Advertisements

Apache Struts Technology
Basic JDBC Celsina Bignoli What is JDBC Industry standard for database- connectivity between the Java language and a wide range of.
1 CMSC 132: Object-Oriented Programming II Java Constructs Department of Computer Science University of Maryland, College Park.
A Framework for Smart Proxies and Interceptors in RMI Nuno Santos P. Marques, L. Silva CISUC, University of Coimbra, Portugal
An Introduction to Hibernate Matt Secoske
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
UPortal Developers MIT August 2004 Persistence Strategy for uPortal 3 Mike DeSimone the r-smart group
Agenda What is Hibernate Spring Integration Questions Overview
Maven for building Java applications By Nalin De Zoysa
Grant Ronald Principal Product Manager JDeveloper and ADF for Forms Developers: Taking it to the next level.
Dynamic Data Exchanges with the Java Flow Processor Presenter: Scott Bowers Date: April 25, 2007.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Seminar on. Overview Hibernate. What is it? Hibernate. How does it work? Hibernate Tools.
Anti Orgla, Nortal AS Spring Framework
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
By: Saurabh Dixit.  Groovy server pages  Taglibs  Validators in grails.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
CS 160: Software Engineering October 1 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Introduction to Web Dimitar Nenchev Ivan Nakov
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Persistence and Hibernate Aaron Zeckoski
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Reporting – Sort Orders, Selections, and Related Data TEC02 Brian Ciccolo.
MCS 270 Spring 2014 Object-Oriented Software Development.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Persistence – Iteration 4 Vancouver Bootcamp Aaron Zeckoski
Jaas Introduction. Outline l General overview of Java security Java 2 security model How is security maintained by Java and JVM? How can a programmer.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Java EE - JSR 303 Bean validation - Pierre-Johan CHARTRE
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Hibernate Basics. Basics What is persistence? Persistence in Object Oriented Applications? Paradigm Mismatch.  The Problem of Granularity.  The Problem.
Java Annotations. Annotations  Annotations are metadata or data about data. An annotation indicates that the declared element should be processed in.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
OpenMRS Create New Module.
Spring JDBC Dima Ionut Daniel. Contents What is Spring JDBC? Overview Spring JDBC Core SQL Exceptions Database Connection Batch Operations Handling BLOB/CLOB.
.  A reference model developed for an important use case (Air Job) including UI widgets, controllers, services and DAOs.  After full requirement analysis.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Audit API : Hints and Tricks Mehdi BELMEKKI, Consultancy Team Alfresco.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
COMP 430 Intro. to Database Systems SQL from application code.
ONAP CLI (Command-Line Interface ) Architecture
Open-O CLI (Command-Line Interface ) Architecture
Chengyu Sun California State University, Los Angeles
CS520 Web Programming Spring – Inversion of Control
CSE 413, Autumn 2002 Programming Languages
Functional Programming with Java
Iteration 1 Presentation
Database Applications (15-415) ORM - Part I Lecture 11, February 11, 2018 Mohammad Hammoud.
CS5220 Advanced Topics in Web Programming Spring – Web MVC
CS5220 Advanced Topics in Web Programming Spring – Web MVC
Chengyu Sun California State University, Los Angeles
…and web frameworks in general
Chengyu Sun California State University, Los Angeles
Subtype Substitution Principle
Aspect Oriented Programming
ITE “A” GROUP 2 ENCAPSULATION.
Presentation transcript:

YAGDAO Yet Another DAO Hibernate Guide

yagdao   Mert Can Akkan  

overview  Popular Java ORM layer  JPA 2.0  Hibernate  Spring 3.0+ Support (optional)  Lightweight  No Implementation Framework  No Static Code Generation  Annotation Based  GenericDAO/CRUD operations  Custom operations

dependency-heaven GroupIdArtifactIdVersionOptional cglib 2.2No commons-logging 1.0.2No org.antlrantlr-runtime3.2No org.slf4jslf4j-log4j No org.apache.geronimo.specsgeronimo-jpa_2.0_spec1.1JPA org.hibernatehibernate-core3.5.1-Finalhibernate org.hibernatehibernate-entitymanager3.5.1-Finalhibernate org.springframeworkspring-beans3.0.4.RELEASEspring support org.springframeworkspring-jdbc3.0.4.RELEASEspring support org.springframeworkspring-orm3.0.4.RELEASESpring support Lightweight framework with minimal dependency

maven dependecy com.altuure com.altuure.yagdao repo.altuure.com default

my first yagdao  easy implementation public interface UserDAO extends GenericDAO { }

quickstart  GenericHibernateDAOFactory userDAO = (UserDAO) GenericHibernateDAOFactory.createInstance(UserDAO.class, sessionAccessor); The GenericHibernateDAOFactory will create instance of given DAO at the runtime

springframework support  package scan feature <yagdao:hibernate id="DAOFactory1" base-package="com.altuure.yagdao.blog.dao" session-factory=" mySessionFactory "/>  one by one definition <yagdao:hibernate base-class="com.altuure.yagdao.blog.dao.UserDAO" session-factory="mySessionFactory"/>

GenericDAO  save(Object entity)  update(Object entity)  load(T id)  loadLazy(T id)  delete(Object object)  delete(T id)  vs….

custom methods create & update  Get rid of all setter and getter operations public interface UserDAO extends GenericDAO = YMethodType.SAVE) User = YMethodType.UPDATE) User updateRoles(long roles); }

custom methods query  Embeded Query type = YMethodType.QUERY, query="select u.username from User u where u. =: “ ) String = " ")String );  Named Query = YMethodType.QUERY,queryName="findBy ") String = " ")String );

custom methods = YMethodType.EXECUTE, query="update User set password=:password") int updateAllPasswords(String newPassword); Tip: All execute methods must return an integer

custom methods = YMethodType.APPEND, select = "pbyte,count(id)", groupBy = "pbyte", having = "count(id)>10") List int i);  APPEND Method handler is a simple query builder in which you can append query strings with not null parameters

custom methods criteria &count(experimental)  Criteria method handler is like append method handler tries to build a query with not null values by parsing query parameters.  Due to incomplete criteria API of hibernate it supports hibernate partially

custom methods = YMethodType.CRITERIA) SearchResultList = "pint", operator = YOperator.GE) Integer arg1); Custom Paging and order is supported Selected field and fetch are supported Grouping and having clauses are not supported

custom methods = YMethodType.COUNT) long = "pint", operator = YOperator.GE) Integer = "pdate", operator = YOperator.LE) Date endDate); Returns only count query result of criteria method To execute both see SearchResultList

smart parameters & return types  YPage: enables order and paging  criteria methods  YLimit: enables only paging  append method  criteria methods  SearchResultList: fetch total size of result list public SearchResultList(List result, long totalCount, YPage paging) { super(result); this.totalCount = totalCount; this.paging = paging; }

paging To add paging to any querying method is easy just add YPage,YLimit as a method = YMethodType.APPEND,orderBy = "id desc") SearchResultList byte arg1,YLimit limit); PS: YLimit is valid in all while YPage is valid on only Criteria Methods

prefetch result size Defining ‘SearchResultList’ as a return type enables a count queires for all = YMethodType.CRITERIA) SearchResultList = "pint", operator = YOperator.GE) Integer arg1);

and more  Object based and method based fetch = "product", "order", "order.customer" }) List findByCustomerCityAndMaxPrice2(…);  projection support at append methods

thanks For more please see sample application: maven jetty:run