Chicago, October 19 - 22,
2010
New Persistence Features in
Spring Roo 1.1
Stefan Schmidt
Agenda
•  Spring Roo’s Approach to Persistence
•  Incremental Database Reverse Engineering
•  Apache Solr / Lucene Integra...
Spring Roo’s Approach to
Persistence
Peristence Choices
•  JPA2 for ORM
–  4 choices of ORM providers
•  Hibernate
•  EclipseLink
•  OpenJPA
•  DataNucleus (DN...
No DAOs?
•  No DAO layer by default
–  Objections:
•  testing
•  separation of concern
•  pluggable implementations
•  non...
Feature Extension Points
•  Add-ons can contribute persistence feature extensions via
ITDs
–  Finder add-on is a good exam...
Incremental Database
Reverse Engineering
Alternatives to Roo’s Incremental DBRE
•  Eclipse “JPA Entities from tables” wizard
–  Generates entities from a JDBC conn...
Limitations of Existing DBRE Tools
•  Lack of incremental reverse engineering
•  Complex and long-winded wizard style inte...
Introducing Roo’s Incremental Database
Reverse Engineering
•  DBRE was the most requested feature for Spring Roo
•  Intros...
How does DBRE work?
•  Uses the standard java.sql.DatabaseMetaData
implementation of your JDK
•  Connects to a live databa...
Spring Roo DBRE Commands
•  database introspect --schema <name> [--file <name>]
–  Displays database metadata in XML forma...
Spring Roo DBRE Commands
•  database reverse engineer [--schema <name>] [--
package <name>]
–  Creates entities in the spe...
Primary Keys
•  Supports single and composite primary keys
–  Creates a separate primary key class for tables having more
...
Entity Relationships
•  Automatically creates and maintains bi-directional
relationships:
–  @ManyToMany, many-valued asso...
DEMO
Database Reverse Engineering Demo
Apache Solr / Lucene
Integration
What is Apache Solr?
•  Search server
•  Built upon Apache Lucene (Java)
•  Fast, very
•  Scalable, query load and collect...
Solr Features
•  Powerful full-text search
•  Hit highlighting
•  Faceted search
•  Spell checking
•  Dynamic clustering
•...
Interacting with Solr
•  HTTP GET / POST
•  JSON / XML
•  SolrJ (embedded over HTTP)
•  Ruby: solr-ruby, RSolr
•  many oth...
Configuring Solr
•  schema.xml
–  Defines field types
–  Can drive more intelligent processing
–  Dynamic Fields enable on...
Roo Solr Integration
•  Roo Shell
–  solr setup  install SolrJ driver in project pom.xml
–  solr add  make individual ty...
Entity Methods Introduced via Roo
•  QueryResponse search(String queryString)
•  QueryResponse search(SolrQuery query)
•  ...
DEMO
Apache Solr
Alternative Persistence
Technologies
Demand for Choice
•  ROO-301: Choose between data access patterns
–  demand for repository and DAO pattern support
•  70+ ...
Hades Add-On
•  Have you heard of Hades project?
–  Utility library to work with Data Access Objects
•  implemented with S...
DEMO
Hades Add-On
Summary
•  Roo has deep and rich persistence support
•  Roo’s Incremental DBRE feature is the next generation in
DBRE capa...
Upcoming SlideShare
Loading in …5
×

New Persistence Features in Spring Roo 1.1

3,155 views

Published on

New Persistence Features in Spring Roo 1.1

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,155
On SlideShare
0
From Embeds
0
Number of Embeds
817
Actions
Shares
0
Downloads
36
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

New Persistence Features in Spring Roo 1.1

  1. 1. Chicago, October 19 - 22, 2010 New Persistence Features in Spring Roo 1.1 Stefan Schmidt
  2. 2. Agenda •  Spring Roo’s Approach to Persistence •  Incremental Database Reverse Engineering •  Apache Solr / Lucene Integration •  Alternative Persistence Technologies
  3. 3. Spring Roo’s Approach to Persistence
  4. 4. Peristence Choices •  JPA2 for ORM –  4 choices of ORM providers •  Hibernate •  EclipseLink •  OpenJPA •  DataNucleus (DN1 supported for GAE, DN2 used by VMforce) •  12+ Database choices –  constantly growning list of DBs to choose from –  popular ones: MySQL, Postgres, HSQLDB (for dev) •  Switch out ORM and / or DB with a single command –  persistence setup --provider HIBERNATE --database MYSQL
  5. 5. No DAOs? •  No DAO layer by default –  Objections: •  testing •  separation of concern •  pluggable implementations •  non JPA persistence •  security authorizations •  security auditing •  finders •  architectural reasons
  6. 6. Feature Extension Points •  Add-ons can contribute persistence feature extensions via ITDs –  Finder add-on is a good example •  Every @RooEntity exposes the JPA entity manager –  use for creating custom type-safe queries via Criteria API –  getting access to the underlying ORM
  7. 7. Incremental Database Reverse Engineering
  8. 8. Alternatives to Roo’s Incremental DBRE •  Eclipse “JPA Entities from tables” wizard –  Generates entities from a JDBC connection –  Can be tailored to change generated type and field names –  Does not handle tables with no primary keys •  JPA Implementation Tools
  9. 9. Limitations of Existing DBRE Tools •  Lack of incremental reverse engineering •  Complex and long-winded wizard style interactions •  Missing entity lifecycle management –  Application requires manual adjustment if the datamodel changes
  10. 10. Introducing Roo’s Incremental Database Reverse Engineering •  DBRE was the most requested feature for Spring Roo •  Introspect relational databases such as Oracle, MySQL, PostgreSQL and Microsoft SQL Server •  Reverse engineer complex schemas into Java entities in seconds •  Creates and maintains relationships with JPA 2.0 annotations •  Incrementally updates your domain model as your DB schema changes
  11. 11. How does DBRE work? •  Uses the standard java.sql.DatabaseMetaData implementation of your JDK •  Connects to a live database using JDBC and creates entities from the database metadata obtained •  Similar to the output generated by the Eclipse wizard with all accepted defaults
  12. 12. Spring Roo DBRE Commands •  database introspect --schema <name> [--file <name>] –  Displays database metadata in XML format in the Roo shell –  Optional --file <file name> saves metadata to specified file –  Provides a preview of the mappings used in the final model
  13. 13. Spring Roo DBRE Commands •  database reverse engineer [--schema <name>] [-- package <name>] –  Creates entities in the specified package –  --schema and --package options required only for first time run of command –  Automatically generates type and field names from table and column names –  JPA-annotated fields and getters/setters saved in AspectJ ITDs, eg Person_Roo_DbManaged.aj
  14. 14. Primary Keys •  Supports single and composite primary keys –  Creates a separate primary key class for tables having more than one primary key or no primary key (uses all fields for key) –  Annotates the primary key class with @Embeddable and the entity's id with @EmbeddedId
  15. 15. Entity Relationships •  Automatically creates and maintains bi-directional relationships: –  @ManyToMany, many-valued associations with many-to- many multiplicity –  @OneToOne, single-valued associations to other entities that have one-to-one multiplicity –  @OneToMany, many-valued associations with one-to-many multiplicity –  @ManyToOne, single-valued associations to other entities that have many-to-one multiplicity
  16. 16. DEMO Database Reverse Engineering Demo
  17. 17. Apache Solr / Lucene Integration
  18. 18. What is Apache Solr? •  Search server •  Built upon Apache Lucene (Java) •  Fast, very •  Scalable, query load and collection size •  Distributed search and index replication •  Interoperable •  Extensible
  19. 19. Solr Features •  Powerful full-text search •  Hit highlighting •  Faceted search •  Spell checking •  Dynamic clustering •  Database integration •  Rich document (e.g., Word, PDF) handling.
  20. 20. Interacting with Solr •  HTTP GET / POST •  JSON / XML •  SolrJ (embedded over HTTP) •  Ruby: solr-ruby, RSolr •  many others: python, PHP, solrsharp, XSLT •  JMX monitoring available •  Admin interface available
  21. 21. Configuring Solr •  schema.xml –  Defines field types –  Can drive more intelligent processing –  Dynamic Fields enable on-the-fly addition of new fields –  CopyField •  indexing a single field multiple ways •  combining multiple fields into a single searchable field –  Many additional text analysis components •  word splitting, •  regex filters •  sounds-like filters
  22. 22. Roo Solr Integration •  Roo Shell –  solr setup  install SolrJ driver in project pom.xml –  solr add  make individual type searchable –  solr all  make all JPA entities searchable •  @RooSolrSearchable type annotation •  Hooks into JPA lifecycle –  @PostPersist –  @PostUpdate –  @PreDelete •  Uses SolrJ client
  23. 23. Entity Methods Introduced via Roo •  QueryResponse search(String queryString) •  QueryResponse search(SolrQuery query) •  @Async void indexPerson(Person person) •  @Async void indexPeople(Collection<Person> people) •  @Async deleteIndex(Owner owner) •  solrServer is also accessible on target type.
  24. 24. DEMO Apache Solr
  25. 25. Alternative Persistence Technologies
  26. 26. Demand for Choice •  ROO-301: Choose between data access patterns –  demand for repository and DAO pattern support •  70+ votes in Spring Roo Jira, second most popular issue –  Spring JDBC template –  demand for iBatis support (ROO-452) –  demand for NoSQL integration –  demand for polyglot persistence
  27. 27. Hades Add-On •  Have you heard of Hades project? –  Utility library to work with Data Access Objects •  implemented with Spring and JPA –  Main goal is to ease the development and operation of a data access layer in applications •  Installation in the Roo shell with a single command: –  addon install --bundleSymbolicName org.synyx.hades.roo.addon –  hades setup –  hades repository --entity ~.domain.Person –  more features planned (finders, DDD, etc)
  28. 28. DEMO Hades Add-On
  29. 29. Summary •  Roo has deep and rich persistence support •  Roo’s Incremental DBRE feature is the next generation in DBRE capabilities •  Solr and Incremental DBRE offer devs a major productivity boost •  Alternative persistence technologies supported and expanding

×