Re: Object without ID in LoadableDetachableModels

2009-05-12 Thread James Carman
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

AW: AW: Object without ID in LoadableDetachableModels

2009-05-12 Thread Christian Helmbold
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

AW: Object without ID in LoadableDetachableModels

2009-05-12 Thread Christian Helmbold
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 -

AW: Object without ID in LoadableDetachableModels

2009-05-09 Thread Christian Helmbold
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

Re: Object without ID in LoadableDetachableModels

2009-05-08 Thread Igor Vaynberg
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

Re: Object without ID in LoadableDetachableModels

2009-05-08 Thread James Carman
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

Object without ID in LoadableDetachableModels

2009-05-08 Thread Christian Helmbold
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