Hi,
We had a look at your log and we think we have found out what is going on. First, the query is being executed correctly. The ejb-ql query selects the following:
line 605:
2004-06-20 23:08:13,977 INFO [STDOUT] CocoPowder:: New Object being instantiated - Props = {F@CBQ@PHONE=1, F@CBQ@FATHER_NAME=Paulo, F@CBQ@EMAIL=Paulo, F@CBQ@GENDER_V_O_ID=1, F@CBQ@CNS_CODE=12345,
F@CBQ@ID=1, F@CBQ@NAME=John Cardoso, F@CBQ@STARTED_DATE=2004-12-30,
F@CBQ@CONTACT=CONTATO DO CASTOR FUNCIONANDO 10 1 1 1,
F@CBQ@MOTHER_NAME=Maria}
line 621:
2004-06-20 23:08:13,988 INFO [STDOUT] CocoPowder:: New Object being instantiated - Props = {F@CBQ@PHONE=1, F@CBQ@FATHER_NAME=Paulo, F@CBQ@EMAIL=luiz@teste.com, F@CBQ@GENDER_V_O_ID=1, F@CBQ@ID=2,
F@CBQ@CNS_CODE=12345, F@CBQ@NAME=John Cardoso, F@CBQ@CONTACT=Paulo 2 2 2 2 2, F@CBQ@MOTHER_NAME=Maria}
line 637:
2004-06-20 23:08:13,998 INFO [STDOUT] CocoPowder:: New Object being instantiated - Props = {F@CBQ@PHONE=1, F@CBQ@FATHER_NAME=Paulo, F@CBQ@EMAIL=luiz@teste.com, F@CBQ@GENDER_V_O_ID=1, F@CBQ@ID=3,
F@CBQ@CNS_CODE=12345, F@CBQ@NAME=John Cardoso, F@CBQ@CONTACT=Maria 3 3 3 3 3, F@CBQ@MOTHER_NAME=Maria}
line 653:
2004-06-20 23:08:14,078 INFO [STDOUT] CocoPowder:: New Object being instantiated - Props = {F@CBQ@PHONE=1, F@CBQ@FATHER_NAME=Paulo, F@CBQ@EMAIL=luiz@teste.com, F@CBQ@GENDER_V_O_ID=1, F@CBQ@ID=4, F@CBQ@CNS_CODE=12345, F@CBQ@NAME=John Cardoso, F@CBQ@CONTACT=Maria,
F@CBQ@MOTHER_NAME=Maria}
However, your navigation model has a link that connects PersonVO to GenderVO and vice-versa. Note that links are bidirectional. So, for instance, when then the gender of "John Cardoso" is loaded, it then tries to load all the PersonVO objects linked to that same gender
(i.e. GENDER_V_O_ID=1) so that closure is obtained for that object graph - as a consequence, the query at line 990 is executed:
2004-06-20 23:08:14,358 INFO [STDOUT] CocoPowder:: OP=<select> query = select
TB_PERSON.ID_PERSON_PK,TB_PERSON.NM_PERSON,TB_PERSON.CD_CNS,TB_PERSON.DT_BIRTH,TB_PERSON.NM_MOTHER,TB_PERSON.NM_FATHER,TB_PERSON.CD_PHONE,TB_PERSON.DS_CONTACT,TB_PERSON.NM_EMAIL,TB_PERSON.ID_GENDER_FK,TB_HEALTH_PROF.DT_STARTED from TB_PERSON , TB_HEALTH_PROF where TB_PERSON.ID_GENDER_FK = ? AND TB_PERSON.ID_PERSON_PK = TB_HEALTH_PROF.ID_PERSON_PK (+)
This will load all persons where TB_PERSON.ID_GENDER_FK = 1 and that's why you see other records such as
2004-06-20 23:08:14,598 INFO [STDOUT] CocoPowder:: New Object being instantiated - Props = {PHONE=12323, EMAIL=charles@teste, GENDER_V_O_ID=1, CNS_CODE=12345, ID=10, CONTACT=Antonio Santos, MOTHER_NAME=Maria Santos, NAME=Charles Marcus, FATHER_NAME=Pedro Santos}
at line 1216 being loaded. And this is correct - it is simply loading all the persons linked to that same gender. Does that make more sense now? To verify what we are saying, try commenting out the line where you specify your navigation model:
// prps.put("cocosource.navmodel","classes_Model");
This will leave your object graph withut any link mappings, and only the "root" PersonVO instances like 'John%' should be loaded. This is only so you can see that it is the link traversal from GenderVo to PersonVO which is causing other PersonVO instances to be loaded.
It is important to keep in mind that links are bidirectional. Now, If you don't want loading to occur from GenderVo to PersonVO, you can simply edit your link model and set "cascade load=false". This should fix your issue. Let us know how it goes.
Hope that helps!
THOUGHT Support
|