> > I've been coding some
> > examples with convoluted entity lazy-loaded associations and, despite
> > my previous fears, detaching/re-attaching it from/to the hibernate
> > session works like a charm. I think I will tag all my editable
> > entities as Serializable and embrace this approach.
>
> Sounds good. Can you share a code snippet?
Yes, I will post one later. Anyway, up till now it goes as simple as:
The entity to update has some associations (of any cardinality), some
of which are lazily-loaded and some of which are eagerly-loaded. If
you need to edit some of the lazy ones, you have to invoke its getter
at some point while constructing the form (this would be normally done
by a form field, so you don't need to explicitly do it). If you don't
want to edit some of the eager associates then (i) if it's small (so
that it really makes sense to make it eager from a db viewpoint)
serialize it anyway into the session (ii) if it's too big then you'd
better turn it into lazy. So in fact most of the time you don't need
to do anything special. Just something like:
class MyForm extends Form {
private Entity entity;
public MyForm(String id, Integer entityId) {
super(id);
entity = entityRepository.findById(entityId);
setModel(new CompoundPropertyModel(entity));
[....]
}
Also with the LDMs approach my service update method will be empty,
its only motivation being that of transactionality:
@Transactional void update(Entity entity) {}
But now it must re-attach the detached entity, so I have to change it into:
@Transactional void update(Entity entity) {
getHibernateTemplate().update(entity);
}
And of course, don't forget to make all involved entities Serializable
(but don't worry about the lazy ones that aren't exposed to the user,
the esoteric stuff they are made of :) will serialize just fine).
That's all, I think.
Cheers,
Carlos
>
> Eelco
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user