Re: generate global uid's
great, thanks! 2006/4/24, Thomas Mahler [EMAIL PROTECTED]: Hi Dennis, org.apache.ojb.broker.util.GUIDFactory produces GUIDs that are unique across different VMs. cheers, Thomas Dennis Bekkering wrote: Hello all, I have a situation where i frequently have to merge data from different databases. Uptill now every database has it's own sequence. That means that i cannot merge the data blindly because two records with the same id might not be the same record. I am thinking of switching from int id's to varchar UID's. Does ojb support such mechanism in an offline manner, so that the two servers do not need to communicate with each other. If all id's are globally unique i can blindly merge data without the danger of overwriting stuff. If ojb does not offer this out of the box then does anybody now a way to generate UID's across systems. Within one system I use java.rmi.server.UID().toString() but i dont know how unique that is across different VM's. Cheers, Dennis - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- mvg, Dennis
anonymous keys
Folks, I have a question regarding anonymous keys. Without them I was successfully using QueryByIdentity to find an object by his PK: Query query = new QueryByIdentity(example); retVal = broker.getObjectByQuery(query); But when I enabled primary keys this approach stopped to work. Any suggestions to how can I use anonymous keys and be able to find object by his PK? -Sergey ** ** LEGAL DISCLAIMER ** ** This E-mail message and any attachments may contain legally privileged, confidential or proprietary information. If you are not the intended recipient(s), or the employee or agent responsible for delivery of this message to the intended recipient(s), you are hereby notified that any dissemination, distribution or copying of this E-mail message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this E-mail message from your computer. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generate global uid's
Hi Dennis, to use OJB's auto-increment feature (automatic assignment of PK's) you have to implement a SequenceManager based on class GUIDFactory. Simply extend AbstractSequenceManager and override public Object getUniqueValue(...) Implement protected int getUniqueId(...) and throw exception within this method (see SequenceManagerMSSQLGuidImpl). regards, Armin Dennis Bekkering wrote: great, thanks! 2006/4/24, Thomas Mahler [EMAIL PROTECTED]: Hi Dennis, org.apache.ojb.broker.util.GUIDFactory produces GUIDs that are unique across different VMs. cheers, Thomas Dennis Bekkering wrote: Hello all, I have a situation where i frequently have to merge data from different databases. Uptill now every database has it's own sequence. That means that i cannot merge the data blindly because two records with the same id might not be the same record. I am thinking of switching from int id's to varchar UID's. Does ojb support such mechanism in an offline manner, so that the two servers do not need to communicate with each other. If all id's are globally unique i can blindly merge data without the danger of overwriting stuff. If ojb does not offer this out of the box then does anybody now a way to generate UID's across systems. Within one system I use java.rmi.server.UID().toString() but i dont know how unique that is across different VM's. Cheers, Dennis - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- mvg, Dennis - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: standalone getDefaultBroker auto-retrieve
Hi Bruno, Bruno CROS wrote: Hi Armin, Here's is a schematic example : Consider a service method that returns an object ProductBean. ProductBean is not O/R mapped but the reading calls a second method that read O/R mapped Product object. Then, relations are followed, to find description of his Category (Consider that a product have 1 Category. 2nd method looks like that (classic): public static Product getProduct(String id) { PersistenceBroker broker = null; try { PersistenceBroker brojer = PersistenceBrokerFactory.defaultPersistenceBroker(); Identity oid = broker.serviceIdentity().buildIdentity(Product.class, id); Product product = (Product) broker.getObjectByIdentity(oid); return product; } finally { if (broker !=null ) { broker.close(); } } } Frst method looks like that : public static ProductBean getProductBean(String id) { Product p = getProduct(id); // 2nd method call if (p!=null) { ProductBean product = new ProductBean(); product.setDescription(p.getDescription()); product.setID(p.getId()); // and here's the O/R recall product.setCategoryDescription( p.getCategory().getDescription() ); // now, broker is open... how does it close ? Sorry, I didn't get it. The Category object associated with Product p was materialized too when getProduct(id) was called (auto-retrieve is true). Why does p.getCategory() open a new PB instance? regards, Armin return product; } return null; } I tried to wrap the code of first method with a tx.open() and tx.abort(), to be sure that broker is released at the end with the abort(). thanks regards. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi, It seems that read objects with a broker, can read related objects by auto-retrieve set to true despite broker is closed. I can't see what you mean. When OJB materialize an object with related objects and auto-retrieve is 'true', the full materialized object is returned. Thus it's not possible to close the PB instance while object materialization (except by an illegal concurrent thread). Or do you mean materialization of proxy references? In this case OJB try to lookup the current PB instance and if not found internally a PB instance is used for materialization and immediately closed after use. Could you please describe more detailed (with example code)? regards, Armin I suppose that a getDefaultBroker is done, and the borrowed broker is never closed (because no reference on it). Note : This occurred because, application has been written with several layers, one for dao, one for services, one for UI. How can i avoid auto-retrieves readings to take brokers in the PBPool by themselves ? 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]
Re: standalone getDefaultBroker auto-retrieve
using proxies ? Oh, i see now. Proxy opens and closes broker well. that's it ? I didn't think to that. Tsss... I'm sorry. It seems that i'm looking for my lost brokers since too much time ago. I guess i'm going to check all my DAOs and all my transactions again (or may be someone else now ;-) ) Thanks again. Bye. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi Armin, Here's is a schematic example : Consider a service method that returns an object ProductBean. ProductBean is not O/R mapped but the reading calls a second method that read O/R mapped Product object. Then, relations are followed, to find description of his Category (Consider that a product have 1 Category. 2nd method looks like that (classic): public static Product getProduct(String id) { PersistenceBroker broker = null; try { PersistenceBroker brojer = PersistenceBrokerFactory.defaultPersistenceBroker(); Identity oid = broker.serviceIdentity().buildIdentity(Product.class, id); Product product = (Product) broker.getObjectByIdentity(oid); return product; } finally { if (broker !=null ) { broker.close(); } } } Frst method looks like that : public static ProductBean getProductBean(String id) { Product p = getProduct(id); // 2nd method call if (p!=null) { ProductBean product = new ProductBean(); product.setDescription(p.getDescription()); product.setID(p.getId()); // and here's the O/R recall product.setCategoryDescription( p.getCategory().getDescription() ); // now, broker is open... how does it close ? Sorry, I didn't get it. The Category object associated with Product p was materialized too when getProduct(id) was called (auto-retrieve is true). Why does p.getCategory() open a new PB instance? regards, Armin return product; } return null; } I tried to wrap the code of first method with a tx.open() and tx.abort(), to be sure that broker is released at the end with the abort(). thanks regards. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi, It seems that read objects with a broker, can read related objects by auto-retrieve set to true despite broker is closed. I can't see what you mean. When OJB materialize an object with related objects and auto-retrieve is 'true', the full materialized object is returned. Thus it's not possible to close the PB instance while object materialization (except by an illegal concurrent thread). Or do you mean materialization of proxy references? In this case OJB try to lookup the current PB instance and if not found internally a PB instance is used for materialization and immediately closed after use. Could you please describe more detailed (with example code)? regards, Armin I suppose that a getDefaultBroker is done, and the borrowed broker is never closed (because no reference on it). Note : This occurred because, application has been written with several layers, one for dao, one for services, one for UI. How can i avoid auto-retrieves readings to take brokers in the PBPool by themselves ? 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]
Re: standalone getDefaultBroker auto-retrieve
Bruno CROS wrote: using proxies ? Oh, i see now. Proxy opens and closes broker well. that's it ? I didn't think to that. Tsss... I'm sorry. It seems that i'm looking for my lost brokers since too much time ago. I guess i'm going to check all my DAOs and all my transactions again (or may be someone else now ;-) ) You could extend or modify the PersistenceBrokerImpl instance and override method public void setClosed(boolean closed) If set 'false' (PB instance was obtained from the pool) throw and catch an exception to trace the current method caller. Override method protected void finalize() If current broker instance is not closed print the stack trace from setClosed-method. Then it will be easy to find broker leaks. I will add a similar behavior till next release. regards, Armin Thanks again. Bye. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi Armin, Here's is a schematic example : Consider a service method that returns an object ProductBean. ProductBean is not O/R mapped but the reading calls a second method that read O/R mapped Product object. Then, relations are followed, to find description of his Category (Consider that a product have 1 Category. 2nd method looks like that (classic): public static Product getProduct(String id) { PersistenceBroker broker = null; try { PersistenceBroker brojer = PersistenceBrokerFactory.defaultPersistenceBroker(); Identity oid = broker.serviceIdentity().buildIdentity(Product.class, id); Product product = (Product) broker.getObjectByIdentity(oid); return product; } finally { if (broker !=null ) { broker.close(); } } } Frst method looks like that : public static ProductBean getProductBean(String id) { Product p = getProduct(id); // 2nd method call if (p!=null) { ProductBean product = new ProductBean(); product.setDescription(p.getDescription()); product.setID(p.getId()); // and here's the O/R recall product.setCategoryDescription( p.getCategory().getDescription() ); // now, broker is open... how does it close ? Sorry, I didn't get it. The Category object associated with Product p was materialized too when getProduct(id) was called (auto-retrieve is true). Why does p.getCategory() open a new PB instance? regards, Armin return product; } return null; } I tried to wrap the code of first method with a tx.open() and tx.abort(), to be sure that broker is released at the end with the abort(). thanks regards. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi, It seems that read objects with a broker, can read related objects by auto-retrieve set to true despite broker is closed. I can't see what you mean. When OJB materialize an object with related objects and auto-retrieve is 'true', the full materialized object is returned. Thus it's not possible to close the PB instance while object materialization (except by an illegal concurrent thread). Or do you mean materialization of proxy references? In this case OJB try to lookup the current PB instance and if not found internally a PB instance is used for materialization and immediately closed after use. Could you please describe more detailed (with example code)? regards, Armin I suppose that a getDefaultBroker is done, and the borrowed broker is never closed (because no reference on it). Note : This occurred because, application has been written with several layers, one for dao, one for services, one for UI. How can i avoid auto-retrieves readings to take brokers in the PBPool by themselves ? 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: standalone getDefaultBroker auto-retrieve
Hi Armin, thanks for solution , but i'm not sure i did get it all !! Can you confirm solution? Well, i understand i have to override setCLosed method to catch when broker open (is borrowed), throw an exception to save a stacktrace with a catch. So , PB remembers his last loan. that's it ? When finalize is done (that means application is ended ?), if broker is not closed (how does i known that ?), i have to retrieve the last stored loan stacktrace, log it and (why not) throw an BrokerNotClosedException. That's it ? Does Abandonned mechanism tells the advance stacktrace? that will be so great. Imagine : broker xxx, time-out 120 s, borrowed by --- stacktrace --- I will try it tomorrow, thanks a lot. Armin. Regards On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Bruno CROS wrote: using proxies ? Oh, i see now. Proxy opens and closes broker well. that's it ? I didn't think to that. Tsss... I'm sorry. It seems that i'm looking for my lost brokers since too much time ago. I guess i'm going to check all my DAOs and all my transactions again (or may be someone else now ;-) ) You could extend or modify the PersistenceBrokerImpl instance and override method public void setClosed(boolean closed) If set 'false' (PB instance was obtained from the pool) throw and catch an exception to trace the current method caller. Override method protected void finalize() If current broker instance is not closed print the stack trace from setClosed-method. Then it will be easy to find broker leaks. I will add a similar behavior till next release. regards, Armin Thanks again. Bye. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi Armin, Here's is a schematic example : Consider a service method that returns an object ProductBean. ProductBean is not O/R mapped but the reading calls a second method that read O/R mapped Product object. Then, relations are followed, to find description of his Category (Consider that a product have 1 Category. 2nd method looks like that (classic): public static Product getProduct(String id) { PersistenceBroker broker = null; try { PersistenceBroker brojer = PersistenceBrokerFactory.defaultPersistenceBroker(); Identity oid = broker.serviceIdentity().buildIdentity( Product.class, id); Product product = (Product) broker.getObjectByIdentity(oid); return product; } finally { if (broker !=null ) { broker.close(); } } } Frst method looks like that : public static ProductBean getProductBean(String id) { Product p = getProduct(id); // 2nd method call if (p!=null) { ProductBean product = new ProductBean(); product.setDescription(p.getDescription()); product.setID(p.getId()); // and here's the O/R recall product.setCategoryDescription( p.getCategory().getDescription() ); // now, broker is open... how does it close ? Sorry, I didn't get it. The Category object associated with Product p was materialized too when getProduct(id) was called (auto-retrieve is true). Why does p.getCategory() open a new PB instance? regards, Armin return product; } return null; } I tried to wrap the code of first method with a tx.open() and tx.abort (), to be sure that broker is released at the end with the abort(). thanks regards. On 4/25/06, Armin Waibel [EMAIL PROTECTED] wrote: Hi Bruno, Bruno CROS wrote: Hi, It seems that read objects with a broker, can read related objects by auto-retrieve set to true despite broker is closed. I can't see what you mean. When OJB materialize an object with related objects and auto-retrieve is 'true', the full materialized object is returned. Thus it's not possible to close the PB instance while object materialization (except by an illegal concurrent thread). Or do you mean materialization of proxy references? In this case OJB try to lookup the current PB instance and if not found internally a PB instance is used for materialization and immediately closed after use. Could you please describe more detailed (with example code)? regards, Armin I suppose that a getDefaultBroker is done, and the borrowed broker is never closed (because no reference on it). Note : This occurred because, application has been written with several layers, one for dao, one for services, one for UI. How can i avoid auto-retrieves readings to take brokers in the PBPool by themselves ? 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]
inner join n:1 how to
I have two classes Product(table=product) and ProductGroup(table=productgroup) ; these two tables are n:1 relationship means 1 row on productgroup may has more than 1 rows on 'produc' table . I want to query to get all fields of product table and 2 field of productgroup table with some conditions for example select product.id , product.name, product.price , product.productgroupid , productgroup.name, productgroup.logo from product a inner join productgroup b on a.productgroupid = b.id . How can i do this with ojb thank in advanced , Regards -- View this message in context: http://www.nabble.com/inner-join-n%3A1-how-to-t1509312.html#a4094471 Sent from the Apache DB - ObjectRelationalBridge Users forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]