Hi Sam

We use Spring to inject them.
Well, somewhere you'll need that logic what class is loaded by which repo - you could of course do it in a more generic way using factories or a kind of a mapper or whatever...
Since we only have around 10 classes, this is easy.

If you use hibernate, you can have it for free since you can instruct hibernate to load the instance given the class and the id, for example:
T entity =  entityManager.find(entityClass, id);

Matt

Sam Barrow wrote:
We have close to a hundred repositories, this wouldn't work. How do you
inject the services into the EntityModel anyway?

On Thu, 2009-11-12 at 08:34 +0100, Matthias Keller wrote:
Hi Sam

What exactly do you mean by repository? Do you have to load every entity from another place? in load(), we have the code to load every possible entity in our implementation, for example:

T entity;
if (this.clazz == User.class) {
    entity = userService.load(...);
} else if (this.clazz == Company.class) {
    entity = companyService.load(...);
} else .....

And so on. In the end, the entity is loaded from wherever it is defined for this class...

Matt

Sam Barrow wrote:
Does anybody how to pass a smart EntityModel (link below) to another
page? We use a different repository for each entity type. I can't get it
to work. I have tried storing the repository as a field on the
EntityModel and using an abstract method on EntityModel to retrieve it.

http://wicketinaction.com/2008/09/building-a-smart-entitymodel/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



--
matthias.kel...@ergon.ch  +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n    smart people - smart software


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to