Dashboard > Struts University > Home > JPA Training Course > JPA Agenda > Register2-JPA-Notes
Register2-JPA-Notes
Added by Ted Husted, last edited by Ted Husted on Dec 07, 2007  (view change)
Labels: 
(None)


Hibernate 3 provides a an extensive but easy-to-use system for vetting data submitted to an entity object.

Presentation - Going Beyond JPA with Hibernate 3

Hibernate 3 is a superset of the JPA. In this session, we look at some of the "added value" extensions offered by Hibernate 3.

  • Criteria Queries
  • Annotation Extensions
  • Validator
  • Search
  • Shards

Workshop - Register extensions

In the lab, we use the Hibernate validator to prevent "garbage" input.

Story: Values submitted by the Register form must be the correct type, and some values are required.

  • Utilize the Hibernate Validator to confirm input with annotations

Prerequisites

  • @NotEmpty
  • @Email
  • @Length

Exercises

  • Use Hibernate Validator classes (org.hibernate.validator.*) to annotate the User entity to realize the extensions to the Register Use Case
    • Username and Password are required
    • Password length must be at least 4 characters and no more than 10
    • Full Name is required
    • From Address and Reply To Addresses must be email addresses
  • Write unit tests to prove the validations work!

Hint code


    

Accomplishments

  • Utilized the Hibernate Validator to confirm input with annotations

Extra Credit

  • Annotate and test Subscription and Protocol
  • Use the @ForeignKey annotation to give the Derby constraints sensible names
  • Use @GeneratedValue to create UUIDs for the User, Subscription, and Protocol IDs.

Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators