Forgein Key Not Set
I have a problem where the forgein key ids are not set in the object or db after the forgein object has been created. TABLE_A -A_ID TABLE_B -B_ID -A_ID In the mappings tableB has a reference descriptor for tableA TableA tableA = new TableA(); TableB tableB = new TableB(); tableB.setA(tableA); At this point the objects are serialized, sent and recreated on the server. getBroker().store(tableA); getBroker().store(tableB); When I look in the db table_b has the value of 0 for a_id. When getBroker().store(tableA) is executed I can see the a_id set in tableB.tableA.a_id but, I do not see the change in tableB.a_id. When table b is stored the value for a_id remains unset with the value of 0 even though tableB.tableA.a_id has the value set to 1 or whatever it was assigned. -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forgein Key Not Set
geez... sometimes when you stare at xml to long the its hard to find the simplest mistakes. I did not have the foreignkey tag in my reference descriptor. problem solved -chris worley I have a problem where the forgein key ids are not set in the object or db after the forgein object has been created. TABLE_A -A_ID TABLE_B -B_ID -A_ID In the mappings tableB has a reference descriptor for tableA TableA tableA = new TableA(); TableB tableB = new TableB(); tableB.setA(tableA); At this point the objects are serialized, sent and recreated on the server. getBroker().store(tableA); getBroker().store(tableB); When I look in the db table_b has the value of 0 for a_id. When getBroker().store(tableA) is executed I can see the a_id set in tableB.tableA.a_id but, I do not see the change in tableB.a_id. When table b is stored the value for a_id remains unset with the value of 0 even though tableB.tableA.a_id has the value set to 1 or whatever it was assigned. -chris worley - 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]
How to execute code before persisting an object
I would like to perform operations on an object before the object is persisted. One thing I would like to do is set a transactionDate field. I want the field to be set on the server side so all records can be set to the same date. What I mean by that is I do not want to set the date as the user flips through wizard pages and have the dates vary by seconds. My base object for all data model objects is CDataModel. I first tried this: public class CDataModel { protected void prepareStore() { // perform pre store operations } public final void store() { prepareStore(); COJBManager.getBroker().store(this); } } However, this does not work for relationships. If A has a instance of B and I call A.store() the performStore() code will of course not execute for B. Is there anyway in I can manage to allow code to be executed for certain objects before it is created in the db? -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to execute code before persisting an object
On 12/5/05, Christopher C. Worley [EMAIL PROTECTED] wrote: I would like to perform operations on an object before the object is persisted. One thing I would like to do is set a transactionDate field. I want the field to be set on the server side so all records can be set to the same date. What I mean by that is I do not want to set the date as the user flips through wizard pages and have the dates vary by seconds. You could implement PersistenceBrokerAware: http://db.apache.org/ojb/docu/guides/advanced-technique.html#Instance+Callbacks but in your case it actually might be more useful to let the database do this (e.g. a timestamp column or one backed by a sequence) ? Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to execute code before persisting an object
Thomas, Thanks. The PersistenceBrokerAware interface will work. While a service request is handled by the server I want all dates such as transaction_date, inovoice_date, completed_date, ... to all be set to to the time the request was received by the server. -chris worley On 12/5/05, Christopher C. Worley [EMAIL PROTECTED] wrote: I would like to perform operations on an object before the object is persisted. One thing I would like to do is set a transactionDate field. I want the field to be set on the server side so all records can be set to the same date. What I mean by that is I do not want to set the date as the user flips through wizard pages and have the dates vary by seconds. You could implement PersistenceBrokerAware: http://db.apache.org/ojb/docu/guides/advanced-technique.html#Instance+Callbacks but in your case it actually might be more useful to let the database do this (e.g. a timestamp column or one backed by a sequence) ? Tom - 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]