RE: How to deploy OJB on Jboss 3.2
Armin, I'm not sure about xdoclet - since this requirement just came out in 3.2 would guess not. Unless they have some sort of 'custom' tag that lets you insert your own element. Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 12:45 AM To: OJB Users List Subject: Re: How to deploy OJB on Jboss 3.2 Hi Alex, great news! Many thanks. Does xdoclet support the depends element? regards, Armin - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Friday, June 20, 2003 2:49 AM Subject: How to deploy OJB on Jboss 3.2 Armin, Found the fix to get OJB to deploy (without having to redeploy) on JBoss 3.2 with its new classloader scheme. The jboss.xml from db-ojb-1.0.rc2-beans.jar must be modified to this: (the change is a new depends element added in) jboss.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE jboss PUBLIC -//JBoss//DTD JBOSS//EN http://www.jboss.org/j2ee/dtd/jboss.dtd; jboss enterprise-beans session ejb-nameODMGSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.ODMGSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ODMGSessionBeanLocal/local-jndi-nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePBSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.PBSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PBSessionBeanLocal/local-jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBeanLocal/local-j ndi- name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBeanLocal/local-jnd i-na me depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBeanLocal/l ocal -jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBeanLocal/loc al-j ndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBeanLocal/local-jn di-n ame depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerPBBeanLocal/local-jndi -nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session /enterprise-beans resource-managers /resource-managers /jboss -Original Message- From: Bates, Alex Sent: Wednesday, June 18, 2003 9:37 PM To: OJB Users List Subject: RE: OJB/JBoss depends on me startup problem - but redeployment works fine! I heard back from the Jboss newsgroup on this one. But not sure exactly how to implement the workaround (Adrian's #3 seems like the best bet). Below is the response from Adrian Bock, JBoss Director of Support - -Original Message- From: Adrian Brock [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 18, 2003 6:42 PM To: [EMAIL PROTECTED] Subject: RE: [JBoss-user] depends on me startup problem - but redeployment works fine! Hi, The changes to the way the transaction manager is deployed have highlighted this problem. The root problem is that an ejb shouldn't be deployed until its declared invokers have started. There are a number of possible workarounds: 1) Make the EJB Deployer depend upon the invoker (no ejbs will be deployed until the invoker starts) 2) Move the transaction manager deployment back into jboss-service.xml (allowing the invoker to start before the scanner starts looking at /deploy) 3) Declare a dependency for each ejb on the invoker(s) in jboss.xml The real fix will be to make (3) automatic. Regards, Adrian Adrian Brock Director of Support Back Office
Re: How to deploy OJB on Jboss 3.2
Hi again, - Original Message - From: Alex Bates [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Friday, June 20, 2003 11:10 AM Subject: RE: How to deploy OJB on Jboss 3.2 Armin, I'm not sure about xdoclet - since this requirement just came out in 3.2 would guess not. I can't find a @jboss.depends tag or something near it. Unless they have some sort of 'custom' tag that lets you insert your own element. Never heared about such a feature. Thus I will add a section in depolyment doc describes the problem and the solution. regards, Armin Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 12:45 AM To: OJB Users List Subject: Re: How to deploy OJB on Jboss 3.2 Hi Alex, great news! Many thanks. Does xdoclet support the depends element? regards, Armin - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Friday, June 20, 2003 2:49 AM Subject: How to deploy OJB on Jboss 3.2 Armin, Found the fix to get OJB to deploy (without having to redeploy) on JBoss 3.2 with its new classloader scheme. The jboss.xml from db-ojb-1.0.rc2-beans.jar must be modified to this: (the change is a new depends element added in) jboss.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE jboss PUBLIC -//JBoss//DTD JBOSS//EN http://www.jboss.org/j2ee/dtd/jboss.dtd; jboss enterprise-beans session ejb-nameODMGSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.ODMGSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ODMGSessionBeanLocal/local-jndi-nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePBSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.PBSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PBSessionBeanLocal/local-jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBeanLocal/local-j ndi- name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBeanLocal/local-jnd i-na me depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBeanLocal/l ocal -jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBeanLocal/loc al-j ndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBeanLocal/local-jn di-n ame depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerPBBeanLocal/local-jndi -nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session /enterprise-beans resource-managers /resource-managers /jboss -Original Message- From: Bates, Alex Sent: Wednesday, June 18, 2003 9:37 PM To: OJB Users List Subject: RE: OJB/JBoss depends on me startup problem - but redeployment works fine! I heard back from the Jboss newsgroup on this one. But not sure exactly how to implement the workaround (Adrian's #3 seems like the best bet). Below is the response from Adrian Bock, JBoss Director of Support - -Original Message- From: Adrian Brock [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 18, 2003 6:42 PM To: [EMAIL PROTECTED] Subject: RE: [JBoss-user] depends on me startup problem - but redeployment works fine! Hi, The changes to the way the transaction manager is deployed have highlighted this problem. The root problem is that an ejb
Thx all:)
Hello guys, I have finished my project, during this project I have used OJB. And I would thanks this list for have help me:) And more particulary to Armin and Thomas who make a great job, they have a lot of work and they always help people:) Thx everyone, I hope use again OJB, See you all :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problems with OJB in a servlet container
Hi Mark, There's some kind of bizarre synchronicity going on here I was just trying my OJB Webapp in Resin for the first time (minutes ago), and I got exactly the same problem. It runs fine in Tomcat, and we've had it going in Websphere too. I've got a hunch that it may have something to do with a XML parser/classpath issue, but I could be speaking complete rubbish. So, I don't think you've missed anything obvious. I can't offer anything more concrete than that, I'm afraid, and as my knowledge of Resin is rather less than nothing, I'm not sure I can spend alot of time investigating it right now. Has anyone else using OJB + Resin got any hints for us ? Cheers, Charles. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 June 2003 11:00 To: OJB Users List Subject: Problems with OJB in a servlet container Hi, I'm new to the world of JDO and OJB, so please bear with me if this is stupid/straightforward. I want to use OJB in a servlet container. I wrote a small (standalone) test application to do all the configuration and such. That one works. I now tried to move everything into a servlet WAR: - the OJB.properties and repository*.xml files in WEB-INF/classes - all libraries in WEB-INF/lib - the code from the standalone app (just creating and retrieving an object) into a java bean that I call from a servlet But I get a java.lang.ExceptionInInitializerError at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl. buildDefaultKey(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl. init(Unknown Source) ... Is there anything obvious that I'm missing (should any libraries or config files be in the servlet containers lib dir)? What is the best way to debug this? Thanks MarkS P.S: I'm using Resin. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with OJB in a servlet container
Maybe you use xalan lib different from OJB original version? it can't parse URL to repository.xml file. OJB don't put XMLreader.parse method in try/catch block so you will not be able to see real situation in the log files :(. -- Best regards, Alexandermailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OJB stable version with ORACLE 9 and WEBSHPERE 5
Hello , some people wrote in this mail list that they has such combination in the production environment. Can you share the version of OJB that you are using and some specific configuration fragments? I use DataSource object defined in WebSphere Server. I don't specify SequenceManager and ConnectionDescriptor in database_repository.xml file ( so OJB use its default implementation, I think ). In the OJB.propeties file I've changed ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl I use ODMG API. so now the questions :) 1. should I specify org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl ? 2. what SequenceManager is better for me, if I've mapped some object into existing tables, that already has some values in their primary key columns? 3. Should I call db.close() method or it will be done automatically? If you use OJB another than 1 rc3, where can I get it, and is there any sense to test such early version? thank you. -- Best regards, Alexander mailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problems with OJB in a servlet container
I have seen this first hand - if you have other XML parser versions that are loading in your JVM, it can and will often keep your repository from being properly parsed. In particular, I saw that it often would be unable to resolve the location of the repository.dtd, even when it was clearly in the classpath. Make sure nothing else is in your jre/lib/ext first, then make sure your parses versions match those released with OJB. -Rob -Original Message- From: Alexander Prozor [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 6:14 AM To: OJB Users List Subject: Re: Problems with OJB in a servlet container Maybe you use xalan lib different from OJB original version? it can't parse URL to repository.xml file. OJB don't put XMLreader.parse method in try/catch block so you will not be able to see real situation in the log files :(. -- Best regards, Alexandermailto:[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: Problems with OJB in a servlet container
Hi We are using OJB in WebLogic and Tomcat without problems, and we use always the java sdk/vm 1.4.1 for including the default XML parser of the standard 1.4.1 API. Can you verify what version of JVM you use ? Regards, Cristian -Original Message- From: Charles Anthony [mailto:[EMAIL PROTECTED] Sent: Freitag, 20. Juni 2003 12:13 To: 'OJB Users List' Subject: RE: Problems with OJB in a servlet container Hi Mark, There's some kind of bizarre synchronicity going on here I was just trying my OJB Webapp in Resin for the first time (minutes ago), and I got exactly the same problem. It runs fine in Tomcat, and we've had it going in Websphere too. I've got a hunch that it may have something to do with a XML parser/classpath issue, but I could be speaking complete rubbish. So, I don't think you've missed anything obvious. I can't offer anything more concrete than that, I'm afraid, and as my knowledge of Resin is rather less than nothing, I'm not sure I can spend alot of time investigating it right now. Has anyone else using OJB + Resin got any hints for us ? Cheers, Charles. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 June 2003 11:00 To: OJB Users List Subject: Problems with OJB in a servlet container Hi, I'm new to the world of JDO and OJB, so please bear with me if this is stupid/straightforward. I want to use OJB in a servlet container. I wrote a small (standalone) test application to do all the configuration and such. That one works. I now tried to move everything into a servlet WAR: - the OJB.properties and repository*.xml files in WEB-INF/classes - all libraries in WEB-INF/lib - the code from the standalone app (just creating and retrieving an object) into a java bean that I call from a servlet But I get a java.lang.ExceptionInInitializerError at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl. buildDefaultKey(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl. init(Unknown Source) ... Is there anything obvious that I'm missing (should any libraries or config files be in the servlet containers lib dir)? What is the best way to debug this? Thanks MarkS P.S: I'm using Resin. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. - 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]
: Commit on underlying connection failed
All what is a Commit on underlying connection I have this on a commit. I update only one table where there is a Clob column type. No read-only option in the repository . ??? Tx ! [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] ERROR: Commit on underlying connection failed, try to rollback [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGe nerator.java:174) at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGen erator.java:431) at COM.ibm.db2.jdbc.app.DB2Connection.commit(DB2Connection.java:640) at com.p6spy.engine.logging.P6LogConnection.commit(P6LogConnection.java:141) at org.apache.ojb.broker.util.batch.BatchConnection.commit(BatchConnection.java :337) at org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localCommit(Connecti onManagerImpl.java:200) at org.apache.ojb.broker.core.PersistenceBrokerImpl.commitTransaction(Persisten ceBrokerImpl.java:385) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.commitTransaction(Del egatingPersistenceBroker.java:120) at org.apache.ojb.odmg.TransactionImpl.commit(TransactionImpl.java:554) at com.jware.persistence.ojb.JwtTransactionImpl.commit(JwtTransactionImpl.java: 102) at com.jware.test.businessobjects.JwtBOACL.setACLInfo(JwtBOACL.java:149) at com.jware.test.businessobjects.ApplicationACL.run(ApplicationACL.java:55) at com.jware.test.businessobjects.ApplicationACL.main(ApplicationACL.java:38)
RE: LongObjectLookup
Hi Thomas, Exactly, What I need is to have a collection of objects sorted by Long, String or Date keys... Thanks for your reply Saman Ghodsian CTO Middle Earth Technologies Ltd. www.metca.com Cell (604)-839-7791 Vancouver, BC Canada -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 2:26 PM To: OJB Users List Subject: Re: LongObjectLookup Hi Saman, Saman Ghodsian wrote: Hi everyone I need anyones suggestion on this one... I'm trying to implement a List indexed by a Long value or a String value attached to an object I don't know exactly what you want to do. Do you want to implement a Map that maps Long or String values to other persistent entity objects? Or something else? please give us some more details, cheers, Thomas Does anyone know which is the best way to go about it? Code samples or hints appreciated Saman Ghodsian CTO Middle Earth Technologies Ltd. www.metca.com Cell (604)-839-7791 Vancouver, BC Canada - 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]
M:N little bug
Hi! Debugging again the M:N relationships, so we can work as expected with proxies I've found the following bug (line 815, PersistenceBrokerImpl) that make an Item be deleted even if we set auto-delete, auto-update=false in non-decomposible: if( col instanceof ManageableCollection) { ((ManageableCollection) col).afterStore(this); } it should not be (but auto-update == auto-delete) if( col instanceof ManageableCollection) { if( !cds.isMtoNRelation() || ( cds.getCascadeDelete() || cds.getCascadeStore() ) ) ((ManageableCollection) col).afterStore(this); } ??? Or we should specify in collection descriptor explicit that this collection is not ManageableCollection (appear that by default the collection is RemovalAwareCollection if we don't specify anything). Thanks, Edson Richter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.490 / Virus Database: 289 - Release Date: 16/6/2003 smime.p7s Description: S/MIME cryptographic signature
tutorial 3 afterStore() instance callback updated for version 1.0
I updated the code in this tutorial to run with version 1.0: public abstract class DBAutoIncremented implements PersistenceBrokerAware { private static final String ID_ATTRIBUTE_NAME = m_id; public void afterDelete(PersistenceBroker broker) throws PersistenceBrokerException { } public void afterInsert(PersistenceBroker broker) throws PersistenceBrokerException { // remove object from cache to ensure we are retrieving a // copy that is in sync with the database. broker.removeFromCache(this); Class clazz = getClass(); ClassDescriptor cld = broker.getClassDescriptor(clazz); PersistentField idField = cld .getFieldDescriptorByName(ID_ATTRIBUTE_NAME) .getPersistentField(); if (hasNotBeenSet(idField)) { // retrieve the object again with a query // on all non-id attributes. Object object = broker.getObjectByQuery( buildQueryOnAllNonIdAttributes(clazz, cld)); if (object == null) { throw new PersistenceBrokerException( cannot assign ID to + this + ( + clazz + ) + because lookup by attributes failed); } // set id attribute with the value // assigned by the database. idField.set(this, idField.get(object)); } } public void afterLookup(PersistenceBroker broker) throws PersistenceBrokerException { } public void afterUpdate(PersistenceBroker broker) throws PersistenceBrokerException { } public void beforeDelete(PersistenceBroker broker) throws PersistenceBrokerException { } public void beforeInsert(PersistenceBroker broker) throws PersistenceBrokerException { } public void beforeUpdate(PersistenceBroker broker) throws PersistenceBrokerException { } /** * after storing a new instance reflect the * autoincremented PK value * back into the PK attribute. */ public void afterStore() { PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); try { // remove object from cache to ensure we are retrieving a // copy that is in sync with the database. broker.removeFromCache(this); Class clazz = getClass(); ClassDescriptor cld = broker.getClassDescriptor(clazz); PersistentField idField = cld .getFieldDescriptorByName(ID_ATTRIBUTE_NAME) .getPersistentField(); if (hasNotBeenSet(idField)) { // retrieve the object again with a query // on all non-id attributes. Object object = broker.getObjectByQuery( buildQueryOnAllNonIdAttributes(clazz, cld)); if (object == null) { throw new PersistenceBrokerException( cannot assign ID to + this + ( + clazz + ) + because lookup by attributes failed); } // set id attribute with the value // assigned by the database. idField.set(this, idField.get(object)); } } finally { PersistenceBrokerFactory.releaseAllInstances(); } } /** * returns a query that identifies an object by all its non- * primary key attributes. * this method is only safe, if these values are unique! */ private Query buildQueryOnAllNonIdAttributes( Class clazz, ClassDescriptor cld) { // note: these are guaranteed to be in the same order FieldDescriptor[] fields = cld.getFieldDescriptions(); Criteria crit = new Criteria(); for (int i = 0; i fields.length; i++) { if (!fields[i].getAttributeName().equals(ID_ATTRIBUTE_NAME)) { Object value = fields[i].getPersistentField().get(this); if (value == null) { crit.addIsNull(fields[i].getAttributeName()); } else { crit.addEqualTo(fields[i].getAttributeName(), value); } } } return QueryFactory.newQuery(clazz, crit); } /** * returns true if attribute idField == 0, * else false. */ private boolean hasNotBeenSet(PersistentField idField) { return (((Integer) idField.get(this)).intValue() == 0); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]