Re: Changing AutoRetrieve on the fly
Robert S. Sfeir wrote: Armin Waibel wrote: I can try to do that. My CVS is from Friday night, is that too out of date? No, should be ok. Do all PB-api test pass on your local system when run OJB test suite (ant junit) against default DB (hsql)? Nope, some fail, but it doesn't look like they're in the same area I am hitting issues with. junit-no-compile-no-prepare: [junit] Running org.apache.ojb.broker.AllTests [junit] Tests run: 347, Failures: 1, Errors: 0, Time elapsed: 39.767 sec That's ok. Assume the failure has to do with the NestedFieldsTest. Await eagerly your test case ;-) Armin [junit] TEST org.apache.ojb.broker.AllTests FAILED [junit] Running org.apache.ojb.odmg.AllTests [junit] [BOOT] INFO: OJB.properties: file:/C:/Documents%20and%20Settings/Robert%20S.%20Sfeir/My% 20Documents/projects/db-ojb/target/test/ojb/OJB.properties [junit] [BOOT] INFO: No value for key 'CollectionProxyClass' [junit] Tests run: 182, Failures: 1, Errors: 2, Time elapsed: 14.971 sec [junit] TEST org.apache.ojb.odmg.AllTests FAILED [junit] Running org.apache.ojb.soda.AllTests [junit] [BOOT] INFO: OJB.properties: file:/C:/Documents%20and%20Settings/Robert%20S.%20Sfeir/My% 20Documents/projects/db-ojb/target/test/ojb/OJB.properties [junit] [BOOT] INFO: No value for key 'CollectionProxyClass' [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 6.128 sec [junit] Running org.apache.ojb.otm.AllTests [junit] Tests run: 77, Failures: 0, Errors: 0, Time elapsed: 17.455 sec - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: I can try to do that. My CVS is from Friday night, is that too out of date? No, should be ok. Do all PB-api test pass on your local system when run OJB test suite (ant junit) against default DB (hsql)? Nope, some fail, but it doesn't look like they're in the same area I am hitting issues with. junit-no-compile-no-prepare: [junit] Running org.apache.ojb.broker.AllTests [junit] Tests run: 347, Failures: 1, Errors: 0, Time elapsed: 39.767 sec [junit] TEST org.apache.ojb.broker.AllTests FAILED [junit] Running org.apache.ojb.odmg.AllTests [junit] [BOOT] INFO: OJB.properties: file:/C:/Documents%20and%20Settings/Robert%20S.%20Sfeir/My% 20Documents/projects/db-ojb/target/test/ojb/OJB.properties [junit] [BOOT] INFO: No value for key 'CollectionProxyClass' [junit] Tests run: 182, Failures: 1, Errors: 2, Time elapsed: 14.971 sec [junit] TEST org.apache.ojb.odmg.AllTests FAILED [junit] Running org.apache.ojb.soda.AllTests [junit] [BOOT] INFO: OJB.properties: file:/C:/Documents%20and%20Settings/Robert%20S.%20Sfeir/My% 20Documents/projects/db-ojb/target/test/ojb/OJB.properties [junit] [BOOT] INFO: No value for key 'CollectionProxyClass' [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 6.128 sec [junit] Running org.apache.ojb.otm.AllTests [junit] Tests run: 77, Failures: 0, Errors: 0, Time elapsed: 17.455 sec - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
I can try to do that. My CVS is from Friday night, is that too out of date? No, should be ok. Do all PB-api test pass on your local system when run OJB test suite (ant junit) against default DB (hsql)? regards, Armin R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: Hi Robert, Robert S. Sfeir wrote: Armin? Any other ideas on this? I think it might be a serious bug we need to nail before 1.0. My object does come back, but no values are being set. Any help would be appreciated. hmm, as I said in my previous mail all (retrieveReference) tests pass with latest CVS, so I think it's not a bug in OJB. Did you try latest from CVS? Could you send my a junit test for your problem? I can try to do that. My CVS is from Friday night, is that too out of date? R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Hi Robert, Robert S. Sfeir wrote: Armin? Any other ideas on this? I think it might be a serious bug we need to nail before 1.0. My object does come back, but no values are being set. Any help would be appreciated. hmm, as I said in my previous mail all (retrieveReference) tests pass with latest CVS, so I think it's not a bug in OJB. Did you try latest from CVS? Could you send my a junit test for your problem? regards, Armin Thanks R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin? Any other ideas on this? I think it might be a serious bug we need to nail before 1.0. My object does come back, but no values are being set. Any help would be appreciated. Thanks R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
I checked test suite and there are some test cases for 'retrieveAllReferences' - all seems to work (Only difference is that you use refresh 'true' in reference-descriptor). Can you verify your result with some logging entry before and after force loading method call? I can, however I removed the refresh="true" and it still behaves the same. ProjectBean is created its values are null. What kind of logging do you want me to put in? R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Robert S. Sfeir wrote: seems my previous mail is lost in space ;-) Think you do the wrong order of commands. First retrieve the Category objects with a query. Then for all Category objects you want to assign references, call PB.retrieveAllReferences/retrieveReference. Or do I misunderstand your post (sorry my bad english)? Not bad at all, I understood... here is the code now... still doesn't work, the ProjectBean is created, but it's values are null: final Query query = QueryFactory.newQuery( Category.class, crit ); broker.beginTransaction(); final List results = ( List ) broker.getCollectionByQuery( query ); broker.commitTransaction(); for( int i = 0; i < results.size(); i++ ) { CategoryBean bean = ( CategoryBean ) results.get( i ); broker.retrieveAllReferences( bean ); CategoryDetailView categorySummary = CategoryDetailView.buildCategoryDetailView( bean ); categories.add( categorySummary ); categorySummary = null; } I checked test suite and there are some test cases for 'retrieveAllReferences' - all seems to work (Only difference is that you use refresh 'true' in reference-descriptor). Can you verify your result with some logging entry before and after force loading method call? Armin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: > Are you saying that as I do my for loop to build my view objects, I > should grab each CategoryBean, and then get the references to it then? yes, that's how it is work currently. Maybe we should allow to override the auto-XXX settings on the fly by add setAutoXXX methods to query object or something similar in 1.1. Would be a nice feature and would allow what you expected. Yup. That would be real nice to have it turned on and off. Think of it like AutoCommit. Sometimes you want to set that to true, and sometimes not. Ok let me ask a question another way, and perhaps the answer is the same... What if I turn auto-retrieve to true by default and then turn on some setting so that it does do the retreiveAllReferences(), is this the same problem? Thanks R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
> Are you saying that as I do my for loop to build my view objects, I > should grab each CategoryBean, and then get the references to it then? yes, that's how it is work currently. Maybe we should allow to override the auto-XXX settings on the fly by add setAutoXXX methods to query object or something similar in 1.1. Would be a nice feature and would allow what you expected. regards, Armin Robert S. Sfeir wrote: Armin Waibel wrote: That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); I don't know your ProjectBean class, but when you create a new object you can't find any reference object - or I'm wrong? ah, I think you do the "wrong turn" and I misunderstood your example. Do after retrieve of the Category objects a final List results = ( List ) broker.getCollectionByQuery( query ); aCategoryObject = ...get from list broker.retrieveAllReferences( aCategoryObject ); call to get all reference objects for all Category instances you want to assign with the appropriate references. I think I know what you mean, but I'm confused about: aCategoryObject = ...get from list aCategoryObject do you mean my CategoryBean? what do you mean ...get from list? Are you saying that as I do my for loop to build my view objects, I should grab each CategoryBean, and then get the references to it then? Thanks R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
seems my previous mail is lost in space ;-) Think you do the wrong order of commands. First retrieve the Category objects with a query. Then for all Category objects you want to assign references, call PB.retrieveAllReferences/retrieveReference. Or do I misunderstand your post (sorry my bad english)? Not bad at all, I understood... here is the code now... still doesn't work, the ProjectBean is created, but it's values are null: final Query query = QueryFactory.newQuery( Category.class, crit ); broker.beginTransaction(); final List results = ( List ) broker.getCollectionByQuery( query ); broker.commitTransaction(); if( results.size() > 0 ) { for( int i = 0; i < results.size(); i++ ) { CategoryBean bean = ( CategoryBean ) results.get( i ); broker.retrieveAllReferences( bean ); CategoryDetailView categorySummary = CategoryDetailView.buildCategoryDetailView( bean ); categories.add( categorySummary ); categorySummary = null; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Hi, Robert S. Sfeir wrote: I am doing a select on Category. a Category bean contains a get and set for a ProjectBean. a Category only relates to one Project. If I do the autoretrieve false then the projectBean object in the Category bean is null. If I set it to true, then it correctly contains a ProjectBean which the category relates to. Now sometimes I just want to get a list of categories, and I could care less that I get the ProjectBean with it, that's too heavy if I want to just display the category id and category name. Other times I need to do the whole thing, like for a category detail view. In that case I want to get all the ProjectBeans along with the category. Does this makes sense? yes of course! So if I understood retrieveAllReferences, it will return all references of the object (ProjectBean) which relate to the category based on the fact that the Query object is querying Category.class. seems my previous mail is lost in space ;-) Think you do the wrong order of commands. First retrieve the Category objects with a query. Then for all Category objects you want to assign references, call PB.retrieveAllReferences/retrieveReference. Or do I misunderstand your post (sorry my bad english)? regards, Armin R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); I don't know your ProjectBean class, but when you create a new object you can't find any reference object - or I'm wrong? ah, I think you do the "wrong turn" and I misunderstood your example. Do after retrieve of the Category objects a final List results = ( List ) broker.getCollectionByQuery( query ); aCategoryObject = ...get from list broker.retrieveAllReferences( aCategoryObject ); call to get all reference objects for all Category instances you want to assign with the appropriate references. I think I know what you mean, but I'm confused about: aCategoryObject = ...get from list aCategoryObject do you mean my CategoryBean? what do you mean ...get from list? Are you saying that as I do my for loop to build my view objects, I should grab each CategoryBean, and then get the references to it then? Thanks R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: Hi, Robert S. Sfeir wrote: ... That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); I don't know your ProjectBean class, but when you create a new object you can't find any reference object - or I'm wrong? I should explain. I am doing a select on Category. a Category bean contains a get and set for a ProjectBean. a Category only relates to one Project. If I do the autoretrieve false then the projectBean object in the Category bean is null. If I set it to true, then it correctly contains a ProjectBean which the category relates to. Now sometimes I just want to get a list of categories, and I could care less that I get the ProjectBean with it, that's too heavy if I want to just display the category id and category name. Other times I need to do the whole thing, like for a category detail view. In that case I want to get all the ProjectBeans along with the category. Does this makes sense? So if I understood retrieveAllReferences, it will return all references of the object (ProjectBean) which relate to the category based on the fact that the Query object is querying Category.class. R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); I don't know your ProjectBean class, but when you create a new object you can't find any reference object - or I'm wrong? ah, I think you do the "wrong turn" and I misunderstood your example. Do after retrieve of the Category objects a final List results = ( List ) broker.getCollectionByQuery( query ); aCategoryObject = ...get from list broker.retrieveAllReferences( aCategoryObject ); call to get all reference objects for all Category instances you want to assign with the appropriate references. Armin regards, Armin Any help is appreciated. R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Hi, Robert S. Sfeir wrote: ... That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); I don't know your ProjectBean class, but when you create a new object you can't find any reference object - or I'm wrong? regards, Armin Any help is appreciated. R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Armin Waibel wrote: Hi Robert, Robert S. Sfeir wrote: I have auto-retreive set to false in all my descriptors currently. Reason I do that is because sometimes I am not interested in getting the related objects, I just want to do a select from the table and just get the data back. However, there are times when I do want to fetch the related objects. So with that, I tried the following code below, but it seems that it's incorrect since my bean still returns a null for the related bean. final Query query = QueryFactory.newQuery( Category.class, crit ); broker.beginTransaction(); final ObjectReferenceDescriptor ord = new ObjectReferenceDescriptor( broker.getClassDescriptor( Project.class ) ); ord.setCascadeRetrieve( true ); OJB couldn't watch your made changes, 'ord' instance was not integrated. Why you don't use PB.retrieveAllReferences PB.retrieveReference for these objects you want to know the reference objects? That's the first thing I tried, but it returns null for my objects, I must not be using the code Right! Project p = new ProjectBean(); //TODO: Replace with Factory call. broker.retrieveAllReferences( p ); final List results = ( List ) broker.getCollectionByQuery( query ); Any help is appreciated. R - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Changing AutoRetrieve on the fly
Hi Robert, Robert S. Sfeir wrote: I have auto-retreive set to false in all my descriptors currently. Reason I do that is because sometimes I am not interested in getting the related objects, I just want to do a select from the table and just get the data back. However, there are times when I do want to fetch the related objects. So with that, I tried the following code below, but it seems that it's incorrect since my bean still returns a null for the related bean. final Query query = QueryFactory.newQuery( Category.class, crit ); broker.beginTransaction(); final ObjectReferenceDescriptor ord = new ObjectReferenceDescriptor( broker.getClassDescriptor( Project.class ) ); ord.setCascadeRetrieve( true ); OJB couldn't watch your made changes, 'ord' instance was not integrated. Why you don't use PB.retrieveAllReferences PB.retrieveReference for these objects you want to know the reference objects? You can modify the metadata using PB.getDescriptorRepository() and manipulate metadata encapsulated by DescriptorRepository. But made changes are *global*, all threads will see made changes, except if you are using metadata profiles managed by MetadataManager (but this isn't trivial to handle). regards, Armin final List results = ( List ) broker.getCollectionByQuery( query ); broker.commitTransaction(); I have a foreign key relationship between Category and Project. I was to select categories in this case and also get the Project objects back with it. Project and Category are Interfaces. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]