Re: PB behavor of Collection item delete ?
thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, Armin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with collection using ODMG API
Hi all- I am having a problem with 1:n collection in OJB using ODMG. Say I have a parent object, lets call it Trouble Ticket T with a collection of Ticket Notes N. Lets say that the objects retrieved in list N are n1, n2, n3. I perform a retrieval from the DB on Object T. Now I have T with a list of child objects N. When I perform an update on object T using the ODMG API, all child objects that were brought in on the retrieval are reinserted on the update even though there were no changes to these objects, so once update is complete I have object T which updated list N, but now I have double the notes associated with object T, so now I have n1, n2, n3, n1, n2, n3. I am using OJB 1.0.4 release. Following is code from repository_user.xml class-descriptor class=com.xxx.xxx.businessobjects.ServiceTicketBO table=service_tickets isolation-level=read-uncommitted field-descriptor name=id column=idSERVICE_TICKET jdbc_type=INTEGER primarykey=true access=readonly autoincrement=true / ... !--other fields-- ... !--reference descriptors-- ... collection-descriptor name=notes element-class-ref=com.xxx.xxx.businessobjects.ServiceTicketNoteBO proxy=false auto-retrieve=true auto-update=none auto-delete=none inverse-foreignkey field-ref=idServiceTicket / orderby name=dateTimeEntered sort=DESC/ /collection-descriptor /class-descriptor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PB behavor of Collection item delete ?
Hi, ABOU LINA wrote: thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly There is no need to handle with RemovalAwareList instances in your POJO's. Using type 'List' is sufficient and on insert of new objects you can use ArrayList, so 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); is valid when insert new objects. But you are right, when updating objects you have to use Collection.remove(...) method. 2. i delete one element B from A : A.getBCollection().remove(o); it's not allowed to replace the old List with a sub-List instance. inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? There is none. That's the main difference between the PB-api and ODMG. The ODMG implementation use a Unit of work pattern (object state detection, detection of new/deleted objects) the PB-api does immediately write objects to DB and does not keep the objects state in mind. For the next major release of OJB we plan to extend the PB-api to support a unit of work pattern with locking. regards, Armin Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, 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: PB behavor of Collection item delete ?
Hi, ok so, i made DAO implementation with OJB PB in a critical project and we are in step of delivring some module of the application (the mainly module now are developped and tested). my question is : 1. what will be the cost of migrating from PB to ODMG. ??? 2. there are some tools making this migration easy and fast ??? 3. in your opinion, the probleme about deleting collection elements justify using ODMG instead of PB ??? 4. Best practice of ODMG and good examples ?? Thanks. On 3/9/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly There is no need to handle with RemovalAwareList instances in your POJO's. Using type 'List' is sufficient and on insert of new objects you can use ArrayList, so 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); is valid when insert new objects. But you are right, when updating objects you have to use Collection.remove(...) method. 2. i delete one element B from A : A.getBCollection().remove(o); it's not allowed to replace the old List with a sub-List instance. inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? There is none. That's the main difference between the PB-api and ODMG. The ODMG implementation use a Unit of work pattern (object state detection, detection of new/deleted objects) the PB-api does immediately write objects to DB and does not keep the objects state in mind. For the next major release of OJB we plan to extend the PB-api to support a unit of work pattern with locking. regards, Armin Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, 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: remove all references.
Hi Vagula, Vagula wrote: Hi All, I have a table A which references tables B C. The auto-retrieve of B C has been set to true. While I retrieve a record from table A can I some how stop the auto-retrieval of B C. Currently it's *not* possible to change the object metadata at runtime in a per session/query manner (there are plans to make this possible in further versions). Alternative, if possible use proxies for your references. In this case OJB will never load referenced objects on retrieve. From OJB 1.0.4 cglib-proxies can be used (OJB.properties file setting) and you only need to set attribute 'proxy' in reference-descriptor and collection-descriptor to true (no need to define interfaces for all referenced classes). http://db.apache.org/ojb/docu/guides/basic-technique.html#Customizing+the+proxy+mechanism Or you disable auto-retrieve and use PB.retrieveAllReferences(...). But take care of side effects. http://db.apache.org/ojb/docu/guides/basic-technique.html#auto-retrieve+setting regards, Armin Thanks and Regards, Vagula CAUTION - Disclaimer * This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS End of Disclaimer INFOSYS*** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with collection using ODMG API
Hi Eric, Eric Kelm wrote: Hi all- I am having a problem with 1:n collection in OJB using ODMG. Say I have a parent object, lets call it Trouble Ticket T with a collection of Ticket Notes N. Lets say that the objects retrieved in list N are n1, n2, n3. I perform a retrieval from the DB on Object T. Now I have T with a list of child objects N. When I perform an update on object T using the ODMG API, all child objects that were brought in on the retrieval are reinserted on the update even though there were no changes to these objects, so once update is complete I have object T which updated list N, but now I have double the notes associated with object T, so now I have n1, n2, n3, n1, n2, n3. Are the PK fields of n1...n3 are populated on the retrieval? I never noticed this problem in OJB 1.0.4. Could you provide some sample code to reproduce this issue? In this case I can setup a test in OJB's test-suite. regards, Armin I am using OJB 1.0.4 release. Following is code from repository_user.xml class-descriptor class=com.xxx.xxx.businessobjects.ServiceTicketBO table=service_tickets isolation-level=read-uncommitted field-descriptor name=id column=idSERVICE_TICKET jdbc_type=INTEGER primarykey=true access=readonly autoincrement=true / ... !--other fields-- ... !--reference descriptors-- ... collection-descriptor name=notes element-class-ref=com.xxx.xxx.businessobjects.ServiceTicketNoteBO proxy=false auto-retrieve=true auto-update=none auto-delete=none inverse-foreignkey field-ref=idServiceTicket / orderby name=dateTimeEntered sort=DESC/ /collection-descriptor /class-descriptor - 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]
Change od Schema during Runtime
Hello, I would like to copy complex objects from schema A to schema B. This would run in a managed environment (JBoss EJB Server) The schema is configured at the XML Mapping, can I change this during runtime like 1) read data from schema A 2) change schema 3) store the same objects to schema B Is the change of the schema only for this transaction? Because the mapping configured at repository XML will be used by other transactions while the copy is running. best regards, Guido
Re: Misc questions
I forgot to tell that to raise this issue i have to clear the persistencer cache, otherwise everything seem's to be ok. 2006/3/7, Jean-Yves Sironneau [EMAIL PROTECTED]: Hello, I looked more precisely at my issue regarding foreign keys not being set, so now i'am using official OJB 1.0.4. The exact issue is that when i persist a new object (that has not been persisted before), the linked object is persisted and the foreign key is set. But when i retrieve an object, then sets the linked object and then persists the main object this time the linked object is not persisted and the foreign key not set. I'am using the following code, to do the persistence, so the linked object is set before that code : Implementation impl = OJB.getInstance(); TransactionExt tx = (TransactionExt) impl.newTransaction(); tx.begin(); tx.markDirty(product); tx.commit(); Can that be the reason ? Is the way OJB is navigating the object graph different for an initial store or an update ? If you want i can try to package up a simple test case from that. Thank you for your help. Jean-Yves 2006/2/20, Jean-Yves Sironneau [EMAIL PROTECTED]: Hello, I have a few unrelated questions regarding OJB : - Is there a way to set the deferrable foreign key constraint setting using OJB xdoclet module ? - When i use anonymous foreign key in a relationship, it's working perfectly for collections, but for simple reference to an object, i have to store the referenced object and then store the object referencing it, otherwise the two objects are created in db but the foreign key id is not set. It's pretty hard to discover it because, when i retrieve the objects they are ok even if the db foreign key is not set. It's just later, if i restart my application for example, that the referenced objects fields are null. So i have two questions : Do you think it's normal behaviour ? And how can i force OJB to retrieve everything from database to be able to test this kind of possible issues ? By the way i'am using CVS version of OJB 1.1 approximately 2-3 months ago and the ODMG API (which is really working fine except for that). - Is the code for OJB 1.1 located in the 1.0 SVN branch ? Because i don't know if i better use OJB 1.0.4 (or future 1.0.5) or the version i got from CVS. Thanks your for your help. Jean-Yves
Re: Misc questions
Hello, I looked more precisely at my issue regarding foreign keys not being set, so now i'am using official OJB 1.0.4. The exact issue is that when i persist a new object (that has not been persisted before), the linked object is persisted and the foreign key is set. But when i retrieve an object, then sets the linked object and then persists the main object this time the linked object is not persisted and the foreign key not set. I'am using the following code, to do the persistence, so the linked object is set before that code : Implementation impl = OJB.getInstance(); TransactionExt tx = (TransactionExt) impl.newTransaction(); tx.begin(); tx.markDirty(product); tx.commit(); Can that be the reason ? Is the way OJB is navigating the object graph different for an initial store or an update ? If you want i can try to package up a simple test case from that. Thank you for your help. Jean-Yves 2006/2/20, Jean-Yves Sironneau [EMAIL PROTECTED]: Hello, I have a few unrelated questions regarding OJB : - Is there a way to set the deferrable foreign key constraint setting using OJB xdoclet module ? - When i use anonymous foreign key in a relationship, it's working perfectly for collections, but for simple reference to an object, i have to store the referenced object and then store the object referencing it, otherwise the two objects are created in db but the foreign key id is not set. It's pretty hard to discover it because, when i retrieve the objects they are ok even if the db foreign key is not set. It's just later, if i restart my application for example, that the referenced objects fields are null. So i have two questions : Do you think it's normal behaviour ? And how can i force OJB to retrieve everything from database to be able to test this kind of possible issues ? By the way i'am using CVS version of OJB 1.1 approximately 2-3 months ago and the ODMG API (which is really working fine except for that). - Is the code for OJB 1.1 located in the 1.0 SVN branch ? Because i don't know if i better use OJB 1.0.4 (or future 1.0.5) or the version i got from CVS. Thanks your for your help. Jean-Yves
Re: bad sql on n-m relation to subclassed object
hi nicolas, we recently fixed a problem concening findObjectByIdentity see 'OJB and the X-Files... :)' in this case the sql looked ok, but the wrong object was materialized. if the problem still persists, could yu please post a testcase so i can try to reproduce it. thanks jakob DELAHAYE Nicolas schrieb: hi Jakob Braeuchi I have this model : A link to A B, C, and D that inherit of A when i would like retreive a object A by findObjectByIdentity, the left out join make a link on A.id = A.idreftoA for each inherited classes. idreftoA is define as primary key and foreigner key of inherited classes. but A has not idreftoA field. I have tried with no link A to A, but it is the same behaviors. how do i make the mapping for A ? best regards Nicolas DELAHAYE Jakob Braeuchi wrote: hi nicolas, i'm pleased the latest version works for you. could you please post the error, or give me a hint where you found discussions about the bug. jakob delahaye.nicolas schrieb: Hi jakob, Ok, it is working with 1.0.4. But if i want retreive the super class alone, a wrong SLQ query is made, I have seen on the forum that is a bug. My question is : do you know if this defect will be fixed on 1.0.5 ? Best regards Nicolas DELAHAYE hi nicolas, ojb just release 1.0.4. could you please try this as well ? jakob Accédez au courrier électronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn) - 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]
ODMG; SequenceManager
Hi, i have DB2 database; i want to make a sequence on primary key of each table and not a global sequence for all table ??? how can i do it ?? thx
Re: PB behavor of Collection item delete ?
i think the coste of using ODMG is very big only looking how in ODMG we query an object. in ODMG it use OQL (like SQL synthaxis where ) so is very diferent to PB wiche use Criteria to build a condition ! what do you think Mr Armine On 3/9/06, ABOU LINA [EMAIL PROTECTED] wrote: Hi, ok so, i made DAO implementation with OJB PB in a critical project and we are in step of delivring some module of the application (the mainly module now are developped and tested). my question is : 1. what will be the cost of migrating from PB to ODMG. ??? 2. there are some tools making this migration easy and fast ??? 3. in your opinion, the probleme about deleting collection elements justify using ODMG instead of PB ??? 4. Best practice of ODMG and good examples ?? Thanks. On 3/9/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly There is no need to handle with RemovalAwareList instances in your POJO's. Using type 'List' is sufficient and on insert of new objects you can use ArrayList, so 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); is valid when insert new objects. But you are right, when updating objects you have to use Collection.remove (...) method. 2. i delete one element B from A : A.getBCollection().remove(o); it's not allowed to replace the old List with a sub-List instance. inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? There is none. That's the main difference between the PB-api and ODMG. The ODMG implementation use a Unit of work pattern (object state detection, detection of new/deleted objects) the PB-api does immediately write objects to DB and does not keep the objects state in mind. For the next major release of OJB we plan to extend the PB-api to support a unit of work pattern with locking. regards, Armin Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, 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]
Spring Transactions
Hi there, I have an implementation of my model with OJB using just PersistenceBroker. Now I'm looking into adding transactional support, looked into ODMG but it seems complex to implement since all my mapping and query is in Broker lingo, so I'm looking at injecting Transaction support for my process methods with spring, that way I shouldn't need to change config files and just one class that interfaces with the Broker. Now, I tried to look for samples outthere found this http://www.springframework.org/node/116 But after setting it up transactions don't seem to be happening. So my questions are. 1- Do I need to use InnoDB on Mysql ? My tables are MyIsam. 2- Am I missing any other feature besides applicationContext setup and deriving my class from PersistenceBrokerDaoSupport? Here is the applicationContext.xml beans !-- Transaction manager for a single OJB PersistenceBroker (alternative to JTA) -- bean id=transactionManager class=org.springframework.orm.ojb.PersistenceBrokerTransactionManager/ bean id=genericProcess class=com.met.process.Generic/ bean id=payrollManager class=org.springframework.transaction.interceptor.TransactionProxyFactoryBe an property name=transactionManager ref local=transactionManager/ /property property name=target ref local=genericProcess/ /property property name=transactionAttributes props prop key=complete*PROPAGATION_REQUIRED/prop prop key=terminate*PROPAGATION_REQUIRED/prop prop key=*PROPAGATION_REQUIRED,readOnly/prop /props /property /bean /beans Thanks Sam
Re: Report Query in ORDER BY
ok. I have no idea what jira is. Could you give me the link? On 3/10/06, Jakob Braeuchi [EMAIL PROTECTED] wrote: hi vasily, you're right. we do not support ordering by subquery. you can open a feature request on jira. jakob Vasily Ivanov schrieb: Hi Jakob, As I understand, report subquery (with Criteria.PARENT_QUERY_PREFIX + id) can be used only in WHERE clause (Criteria class), but not in ORDER BY clause. Have a look: QueryByCriteria.addOrderBy(String, boolean) QueryByCriteria.addOrderBy(FieldHelper) QueryByCriteria.addOrderByAscending(String) QueryByCriteria.addOrderByDescending(String) ... no methods to add report subquery. :( On 3/9/06, Jakob Braeuchi [EMAIL PROTECTED] wrote: hi vasily, you can use Criteria.PARENT_QUERY_PREFIX to prefix an attribute of the subquery. see QueryTest#testSubQuery3 and testSubQuery4. but i've to admit i nver tried it with addOrderBy(). hth jakob Vasily Ivanov schrieb: Hi All, I've got two classes: class Parent: int id String data Collection children class Child: int id String data int parentId Parent parent I need to get collection of parents sorted by the number of children, but I didn't find any way to put Report Query to ORDER BY statement. Here is the code that works: QueryByCriteria query = QueryFactory.newQuery(Parent.class, new Criteria()); query.addOrderByDescending((SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = A0.ID)); persistenceManager.getBroker().getCollectionByQuery(query); This is generated sql: SELECT A0.ID, A0.DATA, (SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = A0.ID) as ojb_col_3 FROM PARENT A0 ORDER BY 3 DESC It works, but I don't like addOrderByDescending hard coded table alias A0. There should be the way to set report subquery as OrderBy which should solve the problem. I changed code to: query.addOrderByDescending((SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = (id))); But it doesn't work because of SqlHelper.splitPath() I guess, it doesn't substitute (id) by column name A0.ID. Any help will be greatly appreciated. Regards, Vasily Ivanov - 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] - 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: Spring Transactions
On 3/9/06, Saman Ghodsian [EMAIL PROTECTED] wrote: I have an implementation of my model with OJB using just PersistenceBroker. Now I'm looking into adding transactional support, looked into ODMG but it seems complex to implement since all my mapping and query is in Broker lingo, so I'm looking at injecting Transaction support for my process methods with spring, that way I shouldn't need to change config files and just one class that interfaces with the Broker. Now, I tried to look for samples outthere found this http://www.springframework.org/node/116 First, you should have a look at the PetStore sample in Spring, which includes OJB support. Also of interest is this: http://staff.osuosl.org/~mckerrj/?p=3. But after setting it up transactions don't seem to be happening. So my questions are. 1- Do I need to use InnoDB on Mysql ? My tables are MyIsam. You should definitely ask this in the Spring forums. Or rather, search the forums - MySql is a commonly used DB so there is bound to be some questions regarding it. 2- Am I missing any other feature besides applicationContext setup and deriving my class from PersistenceBrokerDaoSupport? See the tutorial above. In short, you'll need the LocalDataSourceConnectionFactory that spring provides, in OJB.properties, and you need to declare the transaction wrapping in the applicationContext.xml around your management or DAO objects (management objects are preferred which logically bundle DB accesses provided by one or more DAOs). Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PB behavor of Collection item delete ?
Hi, ABOU LINA wrote: Hi, ok so, i made DAO implementation with OJB PB in a critical project and we are in step of delivring some module of the application (the mainly module now are developped and tested). my question is : 1. what will be the cost of migrating from PB to ODMG. ??? There is no need to completely migrate to ODMG. For all read-only operations the PB-api can still be used without modification. For all insert/update/delete operations use the ODMG-api. Anyway it is possible to use the PB-api within the odmg-api, so there is no need to use OQL-queries within odmg-tx http://db.apache.org/ojb/docu/guides/odmg-guide.html#Access+the+PB-api+within+ODMG All objects read by the PB instance have to be locked *before* you start to modify these objects. http://db.apache.org/ojb/docu/guides/odmg-guide.html#I+don%27t+like+OQL%2C+can+I+use+the+PersistenceBroker+Queries+within+ODMG When using OQL-queries by default OJB lock all received objects, see 'implicit locking' section http://db.apache.org/ojb/docu/guides/odmg-guide.html#Configuration+Properties http://db.apache.org/ojb/docu/guides/odmg-guide.html#The+TransactionExt+Interface But take care not to use PB instances looked up from the PBF within a odmg-tx. 2. there are some tools making this migration easy and fast ??? Sorry, there is no tool. But in the metadata files you only have to change the auto-xxx settings of your references http://db.apache.org/ojb/docu/guides/odmg-guide.html#Specific+Metadata+Settings 3. in your opinion, the probleme about deleting collection elements justify using ODMG instead of PB ??? This depends on your requirements. If you need this behavior we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); then you have to use the odmg-api. 4. Best practice of ODMG and good examples ?? Have a look in the ODMG tutorial, the odmg-guide and in OJB's test-suite classes for the ODMG-api. http://db.apache.org/ojb/docu/tutorials/odmg-tutorial.html http://svn.apache.org/viewcvs.cgi/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/?rev=378044 Sorry, best practice is missing. regards, Armin Thanks. On 3/9/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly There is no need to handle with RemovalAwareList instances in your POJO's. Using type 'List' is sufficient and on insert of new objects you can use ArrayList, so 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); is valid when insert new objects. But you are right, when updating objects you have to use Collection.remove(...) method. 2. i delete one element B from A : A.getBCollection().remove(o); it's not allowed to replace the old List with a sub-List instance. inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? There is none. That's the main difference between the PB-api and ODMG. The ODMG implementation use a Unit of work pattern (object state detection, detection of new/deleted objects) the PB-api does immediately write objects to DB and does not keep the objects state in mind. For the next major release of OJB we plan to extend the PB-api to support a unit of work pattern with locking. regards, Armin Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, Armin
Re: ODMG; SequenceManager
Hi, ABOU LINA wrote: Hi, i have DB2 database; i want to make a sequence on primary key of each table and not a global sequence for all table ??? how can i do it ?? I don't know which SequenceManager you use. http://db.apache.org/ojb/docu/guides/sequencemanager.html Most implementations use a sequence per table by default, except if inheritance/extents are used, in this case it's mandatory that all table of a object hierarchy use the same sequence name. You can force OJB to auto-generate a sequence name or set the sequence-name in the field-descriptor. regards, Armin thx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Report Query in ORDER BY
Vasily Ivanov wrote: ok. I have no idea what jira is. Could you give me the link? It's the OJB issue tracking http://issues.apache.org/jira/browse/OJB regards, Armin On 3/10/06, Jakob Braeuchi [EMAIL PROTECTED] wrote: hi vasily, you're right. we do not support ordering by subquery. you can open a feature request on jira. jakob Vasily Ivanov schrieb: Hi Jakob, As I understand, report subquery (with Criteria.PARENT_QUERY_PREFIX + id) can be used only in WHERE clause (Criteria class), but not in ORDER BY clause. Have a look: QueryByCriteria.addOrderBy(String, boolean) QueryByCriteria.addOrderBy(FieldHelper) QueryByCriteria.addOrderByAscending(String) QueryByCriteria.addOrderByDescending(String) ... no methods to add report subquery. :( On 3/9/06, Jakob Braeuchi [EMAIL PROTECTED] wrote: hi vasily, you can use Criteria.PARENT_QUERY_PREFIX to prefix an attribute of the subquery. see QueryTest#testSubQuery3 and testSubQuery4. but i've to admit i nver tried it with addOrderBy(). hth jakob Vasily Ivanov schrieb: Hi All, I've got two classes: class Parent: int id String data Collection children class Child: int id String data int parentId Parent parent I need to get collection of parents sorted by the number of children, but I didn't find any way to put Report Query to ORDER BY statement. Here is the code that works: QueryByCriteria query = QueryFactory.newQuery(Parent.class, new Criteria()); query.addOrderByDescending((SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = A0.ID)); persistenceManager.getBroker().getCollectionByQuery(query); This is generated sql: SELECT A0.ID, A0.DATA, (SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = A0.ID) as ojb_col_3 FROM PARENT A0 ORDER BY 3 DESC It works, but I don't like addOrderByDescending hard coded table alias A0. There should be the way to set report subquery as OrderBy which should solve the problem. I changed code to: query.addOrderByDescending((SELECT count(1) FROM CHILD AAA WHERE AAA.PARENT_ID = (id))); But it doesn't work because of SqlHelper.splitPath() I guess, it doesn't substitute (id) by column name A0.ID. Any help will be greatly appreciated. Regards, Vasily Ivanov - 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] - 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: PB behavor of Collection item delete ?
ABOU LINA wrote: i think the coste of using ODMG is very big only looking how in ODMG we query an object. in ODMG it use OQL (like SQL synthaxis where ) so is very diferent to PB wiche use Criteria to build a condition ! what do you think Mr Armine As said in my other post, it's possible to use the PB-api (with Criteria based queries) within ODMG and additionally you can tweak the odmg implementation: - Disable implicit locking (lock all objects before modify them by hand) - Disable pessimistic (object) locking and use optimistic locking for critical objects http://db.apache.org/ojb/docu/guides/lockmanager.html regards, Armin On 3/9/06, ABOU LINA [EMAIL PROTECTED] wrote: Hi, ok so, i made DAO implementation with OJB PB in a critical project and we are in step of delivring some module of the application (the mainly module now are developped and tested). my question is : 1. what will be the cost of migrating from PB to ODMG. ??? 2. there are some tools making this migration easy and fast ??? 3. in your opinion, the probleme about deleting collection elements justify using ODMG instead of PB ??? 4. Best practice of ODMG and good examples ?? Thanks. On 3/9/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: thank first, PersistenceBroker *delete elements* from the database that have been removed from the collection only if i do this : for example : A 1:n B 1. i get A from database using OJB Broker. 2. i delete one element B from A : A.getBCollection().remove(o); in this case yes the PB delete the element from database . but in generale we don't invoke remove but we construct a new collection and we set it : 1. get A from database. 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); in this case the element that not figure in bCol are not deleted because i use ArrayList. (in my Application i can't put RemovalAwareList directly There is no need to handle with RemovalAwareList instances in your POJO's. Using type 'List' is sufficient and on insert of new objects you can use ArrayList, so 2. Collection bCol = new ArrayList(); A.setBCollection(bCol); is valid when insert new objects. But you are right, when updating objects you have to use Collection.remove (...) method. 2. i delete one element B from A : A.getBCollection().remove(o); it's not allowed to replace the old List with a sub-List instance. inorder to keep the application independent of OJB classes ...) so what is the solution please ... without using ODMG ? There is none. That's the main difference between the PB-api and ODMG. The ODMG implementation use a Unit of work pattern (object state detection, detection of new/deleted objects) the PB-api does immediately write objects to DB and does not keep the objects state in mind. For the next major release of OJB we plan to extend the PB-api to support a unit of work pattern with locking. regards, Armin Thanks On 3/7/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi, ABOU LINA wrote: Hi, in ojb document : --- Say you use the PB to query an object O that has a collection attribute col with five elements a,b,c,d,e. Next you delete Objects d and e from col and store O again with PersistenceBroker.store(O); PB will store the remaining objects a,b,c. But it will not delete d and e ! If you then requery object O it will again contain a,b,c,d,e !!! i ask if the new version of PB (1.0.4) still behave like this ??? Oops! Seems you found some outdated documentation - I will fix this till next release. With corresponding settings OJB 1.0.4 is able to detect the deleted objects of the 1:n reference. More info see http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto-xxx+setting http://db.apache.org/ojb/docu/guides/advanced-technique.html#which-collection-type regards, 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Change od Schema during Runtime
Hi Guido, Guido Beutler wrote: Hello, I would like to copy complex objects from schema A to schema B. I suppose you mean copy data from one DB to another or from table A to table B within the same DB. This would run in a managed environment (JBoss EJB Server) The schema is configured at the XML Mapping, can I change this during runtime like 1) read data from schema A 2) change schema 3) store the same objects to schema B Is the change of the schema only for this transaction? With default OJB settings no. Because the mapping configured at repository XML will be used by other transactions while the copy is running. Exactly that's the problem. By default OJB use the same object metadata for all transactions/threads, so metadata changes will immediately noticed by all threads. A PB instance can only use one metadata mapping, it's not possible to use different metadata mapping parallel with same PB instance. But it's possible to use different metadata mapping on per thread base. Thus you can read the object using default schema A, then close current PB, load metadata profile B (using the MetadataManager), lookup a new PB instance (now associated with schema B). http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes regards, Armin best regards, Guido - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Spring Transactions
YES you need innoDB, myIsam does not support transactions, i guess you want transactions. regards, Dennis 2006/3/10, Thomas Dudziak [EMAIL PROTECTED]: On 3/9/06, Saman Ghodsian [EMAIL PROTECTED] wrote: I have an implementation of my model with OJB using just PersistenceBroker. Now I'm looking into adding transactional support, looked into ODMG but it seems complex to implement since all my mapping and query is in Broker lingo, so I'm looking at injecting Transaction support for my process methods with spring, that way I shouldn't need to change config files and just one class that interfaces with the Broker. Now, I tried to look for samples outthere found this http://www.springframework.org/node/116 First, you should have a look at the PetStore sample in Spring, which includes OJB support. Also of interest is this: http://staff.osuosl.org/~mckerrj/?p=3. But after setting it up transactions don't seem to be happening. So my questions are. 1- Do I need to use InnoDB on Mysql ? My tables are MyIsam. You should definitely ask this in the Spring forums. Or rather, search the forums - MySql is a commonly used DB so there is bound to be some questions regarding it. 2- Am I missing any other feature besides applicationContext setup and deriving my class from PersistenceBrokerDaoSupport? See the tutorial above. In short, you'll need the LocalDataSourceConnectionFactory that spring provides, in OJB.properties, and you need to declare the transaction wrapping in the applicationContext.xml around your management or DAO objects (management objects are preferred which logically bundle DB accesses provided by one or more DAOs). Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- mvg, Dennis