Skip to end of metadata
Go to start of metadata

Creating your domain model

At this point, you should have gone through at least the Guick Start and preferably Overview as well, and have your environment set-up and be initially familiar with Tynamo, Tapestry and Maven. Start by figuring out what your business objects are, what the relationships between them are and then implement simple entities for each with minimal annotations. Keep your application in a running state as much as possible and work in small increments. Once you've verified your entities are recognized and you can add, update and delete them in your web application, start implementing the relationships between them using the Hibernate annotations.

Implementing Tynamo "POJOs"

Your domain objects are just POJOs, Plain Old Java Objects, they really are - only with a few minor exceptions (smile) First of all, each needs to be marked with @Entity so Hibernate knows this class represents a persistable domain object, and that it should do something about it. Tynamo doesn't use Hibernate's EntityManager that's is a J2EE container feature. Instead, tapestry-hibernate inspects the classes for @Entity annotation that are in a special package named <application-root-package>.entities (by default and as explained in the documentation of tapestry-hibernate-core).

In addition to @Entity, each object needs to have a guaranteed unique identifier. Typically, your entity contains:

@Entity and @Id are the only mandatory additions to a POJO, but it's a good practice to always implement (override) toString(), equals() and hashCode() operations. Tynamo uses toString for example in lists; equals and hashCode are needed to reliably compare object "sameness" based on the object values rather than checking if two object references are pointing to the same instance.

Annotating entities for Tynamo

Tynamo works its magic on assumptions it makes on your code. Sometimes it's right, sometimes not. In cases, the expected behavior is something else you wanted, you can provide more "hints" with annotations for Tynamo to know what to do.

More documentation needed here...

Icon

In the meantime, study the archetype and examples code.

Back to tapestry-model guide or continue to Developing in IDEs

  • No labels