This still doesn't solve the other problems with database-generated
identifiers and Hibernate, namely being able to reliably implement
equals() and hashCode().
On Tue, May 12, 2009 at 10:54 AM, Christian Helmbold
wrote:
>
> Inspired by http://wicketinaction.com/2008/09/building-a-smart-entitymode
One line was missing in the first constructor. Here is the corrected
constructor:
public EntityModel(T entity)
{
this.entity = entity;
entityClass = entity.getClass();
entityId = getEntityId();
}
-
To unsubscribe
Inspired by http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
I created an EntityModel based on JPA annotations. Maybe this is helpful for
somebody with the same question.
Any suggestions to improve the code?
EntityModel.java
-
Thank you, Igor. This looks useful to me. The interesting part seems to be:
public void detach()
{
if (entity != null)
{
if (entity.getId() != null)
{
id = entity.getId();
entity = null;
}
}
}
The id is set while detaching and at then t
http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
-igor
On Fri, May 8, 2009 at 8:21 AM, Christian Helmbold
wrote:
>
> Domain (or model) objects get their IDs from Hibernate on saving in my
> application. When I create a new LoadableDetachableModel with a fresh model
> object with
Can you switch to using UUIDs? That saved me a LOT of headaches!
On Fri, May 8, 2009 at 11:21 AM, Christian Helmbold
wrote:
>
> Domain (or model) objects get their IDs from Hibernate on saving in my
> application. When I create a new LoadableDetachableModel with a fresh model
> object without
Domain (or model) objects get their IDs from Hibernate on saving in my
application. When I create a new LoadableDetachableModel with a fresh model
object without an ID, the LoadableDetachableModel object contains no ID to load
the model object from the DB on the next request.
Because LoadableD