...
Hibernate Entity Strategy
Code Block |
---|
@Persist(HibernatePersistenceConstants.ENTITY)
private User user; |
Entity persistence is provided by either the tapestry-hibernate modules (which extend Tapestry with new features).
In Entity persistence, the field should store a Hibernate (or JPA) entity instance.
Code Block | ||
---|---|---|
| ||
@Persist(HibernatePersistenceConstants.ENTITY) private User user; |
The value stored in the HttpSession is a token for the entity: its Java class name and primary key. When the field is restored in a later request, the entity is reinstantiated re-instantiated using that data.
What is not stored is any changes to the persistent entity that are not committed to the external datastore (the database).
Starting in Tapestry 5.4, it is possible to store a non-persistent entity (a transient entity). A transient entity is stored directly into the HttpSession, and should be Serializable if the application is clustered.
JPA Entity Strategy
The tapestry-jpa module introduces a similar strategy (also with the name "entity"). However, at the current time it may only store a persisted entity (one that has been saved to the database and has a primary key).
Code Block | ||
---|---|---|
| ||
@Persist(JpaPersistenceConstants.ENTITY)
private Account account; |
Persistence Strategy Inheritance
By default the value for the Persist annotation is the empty string. When this is true, then the actual strategy to be used is determined by a search up the component hierarchy.
...
Include Page | ||||
---|---|---|---|---|
|
Code Block | ||
---|---|---|
| ||
@Persist(HibernatePersistenceConstants.ENTITY)
private User user; |
Code Block | ||
---|---|---|
| ||
@Persist(JpaPersistenceConstants.ENTITY)
private Account account; |