Hi patrik,
thx. Could you let me informed about your changes, or at least your
changed files. Because I'm working on a branch, these would ease merging
your changes with my code.
For lazy initialization I think ???2one references shouldn't be lazy and
so they can handled like hibernate components and not with
populateAsociations.
My current try to improve the populate code ended with:
----
RichFaultBase.class:
@SuppressWarnings("unchecked")
public RichPerson getCaller() {
if (caller == null) {
if (populated == null) {
populated =
associationLoader.populateAssociations(original);
}
if (populated.getCaller() != null) {
//caller = new RichPerson();
try {
caller =
richPersonRepository.findById(populated.getCaller()
.getId());
} catch (PersonNotFoundException e) {
// TODO should throw an exception?
caller.fromModel(populated.getCaller());
}
}
//if (original != null && populated == null &&
associationLoader != null) {
// populated =
associationLoader.populateAssociations(original);
//
// if (populated.getCaller() != null) {
//
// caller = new RichPerson();
// caller.fromModel(populated.getCaller());
// } else {
// caller = null;
// }
}
return caller;
}
----
That problem here is, that if the caller is really null, the the
populated.getCaller() is called each time I call this.getCaller(). But
thats not really bad? If only ??2many-associations are lazy, here we got
an empty collection on the first call, and all is fine.
I've delegated the creation of the new RichPerson-Object to the
RichPersonRepository. Side effect is, all needed Repositories must be
injected in the RichFault-class, wich is not very nice. I better
solution seems to be to delegate the populateAssociations-logic, here
"getCaller(original)" directly to the RichFaultRepository. This would
separate all creation logic into the repositories.
To all repositories, I've added a findById:
----
/**
* @throws PersonNotFoundException
*/
public RichPerson findById(Long id) throws PersonNotFoundException {
Person foundPerson =
personService.findById(createServiceContext(), id);
RichPerson richPerson = null;
// an exception is thrown, if no objects exists for this id
//if (foundPerson != null) {
richPerson = richPersonFactory.create();
richPerson.fromModel(foundPerson);
this.richPersons.put(foundPerson.getKey(), richPerson);
//}
return richPerson;
}
----
What I've also done, is the to create src-gen/RichFaultBase and
src/RichFault-(Impl) classes, like the pattern in the backend. This
allows to implement some presentation logic in the Impl-class of each
Enity. It seems to be very helpful.
And for the backend I've added an I?? e.g. IFault-interface, which
contains all getter methods from the Entity classes. This allows to
implement some sophisticated dynamic proxy magic to e.g. filter and
search boxes without the need to concatenate the constants from e.g.
FaultNames.
You are interested in code? If true, I would create an JIRA-entry for
that and add a patch against my 1.5.0-branch vom beginning of december.
Also for the "T save(T entity)"-methods in the backend service.
I'm using the RichGrudGuiObject, RichCrudGuiRepository and
RichCrudGuiSpring as base for our RAP-frontend.
So now that I know you are working on the lazyloading stuff I will
concentrate me on the entity filters.
Have a nice 2. christmas day.
Regards
Steffen...
Patrik Nordwall schrieb:
> I am testing and bugfixing right now. This is one of the problems I have
> fixed. I will not be able to commit until the 5th. /patrik
>
> Steffen Stundzig wrote:
>> Hi,
>>
>> I've deployed my backend application, based on 1.5.0-SNAPSHOT to my
>> jboss-4.2.2GA. I'm now starting my RCP frontend and try to load some data.
>>
>> My model contains e.g.:
>> Entity Fault {
>> scaffold
>> - @Person caller
>> }
>> Entity Person {
>> scaffold
>> String firstname nullable
>> - @Address address
>> }
>> BasicType Address {
>> String street nullable
>> }
>>
>> If I load a fault and call getCaller() on it, I got the following
>> exception:
>>
>> org.hibernate.LazyInitializationException: could not initialize proxy - no
>> Session
>> at
>> org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
>> at
>> org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
>> at
>> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
>> at
>> de.itemis.mitgas.stm.backend.person.domain.Person_$$_javassist_0.getAddress(Person_$$_javassist_0.java)
>> at
>> de.itemis.mitgas.stm.backend.person.richclient.data.RichPersonBase.fromModel(RichPersonBase.java:305)
>> at
>> de.itemis.mitgas.stm.backend.fault.richclient.data.RichFaultBase.getCaller(RichFaultBase.java:322)
>>
>> The generated methods are:
>> RichFaultBase:
>> public RichPerson getCaller() {
>> if (original != null && populated == null && associationLoader !=
>> null) {
>> populated = associationLoader.populateAssociations(original);
>>
>> if (populated.getCaller() != null) {
>> caller = new RichPerson();
>> caller.fromModel(populated.getCaller()); //line 322
>> } else {
>> caller = null;
>> }
>> }
>> return caller;
>> }
>>
>> and RichPerson:
>> public void fromModel(Person model) {
>> original = model;
>>
>> populated = null;
>>
>> setAddressStreet(model.getAddress().getStreet()); // line 305
>> ....
>> }
>>
>> Whats wrong here? Why does the object at client side needs/knows the
>> hibernate sessions from the last findAll<Fault>() method call?
>>
>> Could I use BasicType here?
>>
>> Regards
>> Steffen...
>>
>
--
Steffen Stundzig
Telefon: +49 (0) 341 / 231-0183-401
Telefax: +49 (0) 341 / 231-0183-411
Mobil: +49 (0) 151 / 173-9673-1 (!neu)
http://itemis.de
[email protected]
https://www.xing.com/profile/Steffen_Stundzig
itemis AG
Niederlassung Leipzig
Ludwig-Erhard-Straße 51
04103 Leipzig
Rechtlicher Hinweis:
Registergericht: Amtsgericht Dortmund HRB 20621
Sitz der Gesellschaft: 44536 Lünen, Am Brambusch 15-24
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vorsitzender), Stephan Grollmann,
Michael Neuhaus
------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer