Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SQL Fácil no Android com QueryDSL

SQL Fácil no Android com QueryDSL

Se você já sentiu que estava voltando no tempo ao ter que manipular SQL no Android, você não está sozinho. Afinal, depois do Hibernate e JPA muitos desenvolvedores ficaram mal acostumados com objetos. Entretanto esses frameworks são demais para um ambiente móvel. QueryDSL traz para o mundo Android a volta da construção de SQL de modo type-safe e autocompletável de um modo rápido e eficiente. Manipular SQLite nunca mais será visto como algo trabalhoso…

Edson Yanaga

August 06, 2014
Tweet

More Decks by Edson Yanaga

Other Decks in Technology

Transcript

  1. S Q L F Á C I L N O A N D R O I D
    C O M Q U E R Y D S L
    E d s o n Ya n a g a
    @ y a n a g a
    # T D C 2 0 1 4

    View Slide

  2. E D S O N YA N A G A
    • Bacharel em Ciência da Computação/UEM
    • Mestre em Engenharia Elétrica/UTFPR
    • Desenvolvedor Java desde 1997
    • Administrador Unix desde 1999
    • Líder Técnico na Produtec desde 2012
    • Instrutor Líder da GlobalCode desde 2012

    View Slide

  3. C E R T I F I C A Ç Õ E S
    • Oracle Certified Professional, Java Platform, Enterprise Edition 6
    Enterprise JavaBeans Developer
    • Sun Certified Enterprise Architect for the Java
    Platform,Enterprise Edition 5 (i)
    • Certified ScrumMaster
    • Sun Certified Developer for Java Web Services 5
    • Sun Certified Specialist for NetBeans IDE
    • Sun Certified Web Component Developer for J2EE 1.4
    • Sun Certified Programmer for Java 2 Platform 1.4

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. M Ó D U L O S PA R A :
    S Q L
    J PA
    M O N G O D B
    L U C E N E

    View Slide

  8. CriteriaQuery query = builder.createQuery();!
    Root men = query.from( Person.class );!
    Root women = query.from( Person.class );!
    Predicate menRestriction = builder.and(!
    ! builder.equal( men.get( Person_.gender ), Gender.MALE ),!
    ! builder.equal( men.get( Person_.relationshipStatus ),!
    RelationshipStatus.SINGLE ));!
    Predicate womenRestriction = builder.and(!
    ! builder.equal( women.get( Person_.gender ), Gender.FEMALE ),!
    ! builder.equal( women.get( Person_.relationshipStatus ),!
    RelationshipStatus.SINGLE ));!
    query.where( builder.and( menRestriction, womenRestriction ) );!

    View Slide

  9. JPAQuery query = new JPAQuery(em);!
    QPerson men = new QPerson("men");!
    QPerson women = new QPerson("women");!
    query.from(men, women).where(!
    ! men.gender.eq(Gender.MALE),!
    ! men.relationshipStatus.eq(RelationshipStatus.SINGLE),!
    ! women.gender.eq(Gender.FEMALE),!
    ! women.relationshipStatus.eq(RelationshipStatus.SINGLE));!

    View Slide

  10. View Slide

  11. D ATA B A S E M I G R AT I O N S

    View Slide

  12. J AVA E S Q L

    View Slide

  13. View Slide

  14. View Slide

  15. S O F T W A R E M E L H O R PA R A U M
    M U N D O M E L H O R

    View Slide

  16. E D S O N YA N A G A
    !
    e d s o n @ y a n a g a . c o m . b r
    @ y a n a g a
    w w w. y a n a g a . c o m . b r

    View Slide