First render thanks for your replies.
@vov: If i use this:
public IModel<Entity> model(Entity entity)
{
return new Model<Entity>(entity);
}
In this case the memory footprint of the session grows because you return
Model object that is not a transient object(or this is what I've read in
wicket documentation...!!) . ¿This means that if you dataview have 100 rows
you have 100 Model<Entity> stored in your session?
¿To avoid this do not exist LoadableDetachableModel what is detached after
page rendering?
@James Carman:
This is the aspect of the most LoadableDetachableModel used in DataView
examples. Specifically in wicket official examples. For each row in DataView
this create new DetachableContactModel , store his ID. After in method
populateItem of Dataview, getModelObject() call result in direct call to
DetachableContactModel.load() that again return object to a database.
Using hibernate this object is cached (or so I have understood), but if use
hand made DAO (like me) that simply query and return a POJO populated this
result in more database conections and querys! Am I right?
public class DetachableContactModel extends LoadableDetachableModel
{
private long id;
protected ContactsDatabase getContactsDB()
{
return DatabaseLocator.getDatabase();
}
/**
* @param c
*/
public DetachableContactModel(Contact c)
{
this(c.getid())
}
/**
* @param id
*/
public DetachableContactModel(long id)
{
if (id == 0)
{
throw new IllegalArgumentException();
}
this.id = id;
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode()
{
return Long.valueOf(id).hashCode();
}
/**
* used for dataview with ReuseIfModelsEqualStrategy item reuse strategy
*
* @see org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object obj)
{
if (obj == this)
{
return true;
}
else if (obj == null)
{
return false;
}
else if (obj instanceof DetachableContactModel)
{
DetachableContactModel other = (DetachableContactModel)obj;
return other.id == this.id;
}
return false;
}
/**
* @see org.apache.wicket.model.LoadableDetachableModel#load()
*/
@Override
protected Object load()
{
// loads contact from the database
return getContactsDB().get(id);
}
}
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Perfomance-of-IDataProvider-tp3325777p3328345.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]