Re: ODMG intialization.
Hi, connections. ( I also call db.close() after each operations ). is not necessary. Close the database only before open another. Or I just call db.open(...) the first time? yep, that's recommended It's is possible to share db among the different threads? yep! Should I close something at any time, apart committing/aborting transactions? no Using in multithreaded environment this could be done only once: Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); db.open(dbName, Database.OPEN_READ_WRITE); Implementation class is threadsafe. HTH regards, Armin - Original Message - From: Alexander Prozor [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Thursday, June 05, 2003 8:52 AM Subject: ODMG intialization. Hello , I can't find answer for this question... But I have a some strange trouble and it looks like I didn't close connections. ( I also call db.close() after each operations ). Should I call another finalized methods? thank you. From: Mauricio CASTRO [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Saturday, May 24, 2003, 10:30:52 PM If I am using ODMG in a multithreaded application. Should I call for each thread the following code? Implementation instance = OJB.getInstance(); Database db = instance.newDatabase(); file://open database db.open(dbName, Database.OPEN_READ_WRITE); odmg.set(instance); Or I just call db.open(...) the first time? It's is possible to share db among the different threads? Should I close something at any time, apart committing/aborting transactions? -- Best regards, Alexander mailto:[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: refreshing a connection
Hi, use 'validationQuery' in your jdbc-connection-descriptor. Then OJB do a 'real' query before a connection was returned. This is a minor performance impact, but this should solve your problem. regards, Armin - Original Message - From: luke cassady-dorion [EMAIL PROTECTED] To: 'OJB Users List' [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 7:32 PM Subject: refreshing a connection A requirement for my application is that the application can continue to service requests even if the database connection is severed. In order to do this, i'm putting insert requests into a queue and pushing them back on if they fail. What i'm finding tho is that the if the db is started and stopped that the ojb connection pool does not refresh itself nor can i force the pool to replace the connection with a new one. Am i missing something? I'm using mssql server if that matters. - 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: Possible OJB Bug with Oracle
Hello, when I yesterday switch to oracle I came across the same exception and I investigated a bit, and found an unexpected situation in the PlatformOracleImpl.java in the setObjectForStatement( ) method the sqlType was Type.INTEGER and the value was a String class both arguments were passed to the PlatformDefaultImpl.java where they were passed into the PreparedStatement. the String class seemed to be already wrong at this place, but a simple hack does work fine for me: *** PlatformOracleImpl.javaSun May 4 14:08:14 2003 --- src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Jun 5 09:17:58 2003 *** *** 126,131 --- 126,138 ps.setLong(index, ((Integer) value).intValue()); } + else if (sqlType == Types.INTEGER value instanceof String) + { + // workaround: + ps.setInt(index, Integer.parseInt( (String) value ) ); + } else { + this.logger.debug( using type + sqlType + for class + value.getClass().getName() ++ ( + value + ) ); super.setObjectForStatement(ps, index, value, sqlType); } maybe this also helps to find the real bug !!! with best wishes Kristian Brown, Melonie S. - Contractor wrote: Has anybody else ran into this? This is a big problem for us, and I'm catching a lot of flack since I recommended we use OJB. It appears that OJB is generating a getCollection query even though the code specifies a single object. I'm not sure where to begin debugging, so any assistance would be greatly appreciated. Original Message Subject: [RC3] Works with MySql, Fails with ClassCastException with Oracle Date: Thu, 29 May 2003 11:41:00 -0400 From: Brown, Melonie S. - Contractor [EMAIL PROTECTED] Reply-To: OJB Users List [EMAIL PROTECTED] Newsgroups: gmane.comp.jakarta.ojb.user I have code that works perfectly fine in MySQL but crashes and dies against an Oracle database. I'm getting a java.lang.ClassCastException at GetCollectionByQuery which doesn't make sense since I'm calling broker.getObjectbyQuery. Also, no SQL statements show in the spy.log file. Suggestions would be greatly appreciated. This is the code: public static RcioDB retrieveRcio(RcioDB sRcio) throws DataStoreException { PersistenceBroker broker = GetAccess.getPersistenceBroker(); try { broker.beginTransaction(); Criteria crit = new Criteria(); crit.addEqualTo( Constants.RCIO_ID, String.valueOf(sRcio.getRcio_ID())); System.out.println(criteria set); QueryByCriteria query = QueryFactory.newQuery(RcioDB.class, crit); System.out.println(query created); Object theRcioToBeFetched = broker.getObjectByQuery(query); System.out.println(after fetch); System.out.println(theRcioToBeFetched.getClass()); return (RcioDB)theRcioToBeFetched; } catch (Throwable t) { t.printStackTrace(); throw new DataStoreException(t.toString()); } finally { broker.close(); } This is the output from the log: criteria set query created [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback was called, do rollback on current connection [EMAIL PROTECTED] org.apache.ojb.broker.PersistenceBrokerException: java.lang.ClassCastException at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis tenceBrokerImpl.java:1467) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis tenceBrokerImpl.java:1496) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis tenceBrokerImpl.java:1485) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Persistenc eBrokerImpl.java:1747) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele gatingPersistenceBroker.java:271) at mil.army.forscom.tsamsweb.rcio.database.RcioCRUD.retrieveRcio(RcioCRUD.java: 131) at mil.army.forscom.tsamsweb.rcio.tests.InsertRciosTest.testInsertRcios(InsertR ciosTest.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at
Please help: How to delete a reference
Hello, I have a Workstation class which contains the reference wntWorkstation to another class WntWorkstation (there is a 1:1 relationship). How could I delete in Workstation the reference wntWorkstation AND the object referenced in WntWorksation table?? Thanks Sylvain Note: the mailing-list archives search doesn't work, you can't view the messages. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re[2]: ODMG intialization.
Hi, sounds strange! Could you give some more information. Code snip, OJB version, repository_database.xml file. regards, Armin - Original Message - From: Alexander Prozor [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED]; Armin Waibel [EMAIL PROTECTED] Sent: Thursday, June 05, 2003 9:45 AM Subject: Re[2]: ODMG intialization. Hello Armin, Ok, but I still have problem with Active connections. Try to take example, when I set activeconnections = 10. I can open my page for a 3 times before server crashed ( it contains some db call ). when I set activeconnections = 40 I can do it for 10 times :). and so on. so I am think that I should release connection somewhere. but where? connections. ( I also call db.close() after each operations ). AW is not necessary. Close the database only before open another. Or I just call db.open(...) the first time? AW yep, that's recommended It's is possible to share db among the different threads? AW yep! Should I close something at any time, apart committing/aborting transactions? AW no AW Using in multithreaded environment this could be AW done only once: AW Implementation odmg = OJB.getInstance(); AW Database db = odmg.newDatabase(); AW db.open(dbName, Database.OPEN_READ_WRITE); AW Implementation class is threadsafe. AW HTH AW regards, AW Armin AW - Original Message - AW From: Alexander Prozor [EMAIL PROTECTED] AW To: OJB Users List [EMAIL PROTECTED] AW Sent: Thursday, June 05, 2003 8:52 AM AW Subject: ODMG intialization. Hello , I can't find answer for this question... But I have a some strange trouble and it looks like I didn't close connections. ( I also call db.close() after each operations ). Should I call another finalized methods? thank you. From: Mauricio CASTRO [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Saturday, May 24, 2003, 10:30:52 PM If I am using ODMG in a multithreaded application. Should I call for AW each thread the following code? Implementation instance = OJB.getInstance(); Database db = instance.newDatabase(); file://open database db.open(dbName, Database.OPEN_READ_WRITE); odmg.set(instance); Or I just call db.open(...) the first time? It's is possible to share db among the different threads? Should I close something at any time, apart committing/aborting transactions? -- Best regards, Alexander mailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] AW - AW To unsubscribe, e-mail: [EMAIL PROTECTED] AW For additional commands, e-mail: [EMAIL PROTECTED] -- 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]
map mapping
Hello, I have a class with a map type attribute. I've try to store it using object to byte array conversion but it seems to not work. There are no errors during the storage, but when I list rows from the table, the corresponding column is empty whereas when debugging the converter it returns a byte array. What the problem ? This is the java declaration : Map dataType = new HashMap(); This is the reposity part : field-descriptor name=dataType column=TYPE_DECLARATION_DATA_TYPE jdbc-type=VARBINARY / conversion=org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion / -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Possible OJB Bug with Oracle
Hi Kristian, For me this does not look like a OJB bug, but as a configuration problem. If you have a java attribute of type String but have defined it as INTEGER in the repository.xml you've got a problem! If you want to have a String attribute converted into an Oracle Number column you should use a FieldConversion but not change the PlatformOracleImpl. cheers, thomas -Original Message- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 9:46 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle Hello, when I yesterday switch to oracle I came across the same exception and I investigated a bit, and found an unexpected situation in the PlatformOracleImpl.java in the setObjectForStatement( ) method the sqlType was Type.INTEGER and the value was a String class both arguments were passed to the PlatformDefaultImpl.java where they were passed into the PreparedStatement. the String class seemed to be already wrong at this place, but a simple hack does work fine for me: *** PlatformOracleImpl.javaSun May 4 14:08:14 2003 --- src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Jun 5 09:17:58 2003 *** *** 126,131 --- 126,138 ps.setLong(index, ((Integer) value).intValue()); } + else if (sqlType == Types.INTEGER value instanceof String) + { + // workaround: + ps.setInt(index, Integer.parseInt( (String) value ) ); + } else { + this.logger.debug( using type + sqlType + for class + value.getClass().getName() ++ ( + value + ) ); super.setObjectForStatement(ps, index, value, sqlType); } maybe this also helps to find the real bug !!! with best wishes Kristian Brown, Melonie S. - Contractor wrote: Has anybody else ran into this? This is a big problem for us, and I'm catching a lot of flack since I recommended we use OJB. It appears that OJB is generating a getCollection query even though the code specifies a single object. I'm not sure where to begin debugging, so any assistance would be greatly appreciated. Original Message Subject: [RC3] Works with MySql, Fails with ClassCastException with Oracle Date: Thu, 29 May 2003 11:41:00 -0400 From: Brown, Melonie S. - Contractor [EMAIL PROTECTED] Reply-To: OJB Users List [EMAIL PROTECTED] Newsgroups: gmane.comp.jakarta.ojb.user I have code that works perfectly fine in MySQL but crashes and dies against an Oracle database. I'm getting a java.lang.ClassCastException at GetCollectionByQuery which doesn't make sense since I'm calling broker.getObjectbyQuery. Also, no SQL statements show in the spy.log file. Suggestions would be greatly appreciated. This is the code: public static RcioDB retrieveRcio(RcioDB sRcio) throws DataStoreException { PersistenceBroker broker = GetAccess.getPersistenceBroker(); try { broker.beginTransaction(); Criteria crit = new Criteria(); crit.addEqualTo( Constants.RCIO_ID, String.valueOf(sRcio.getRcio_ID())); System.out.println(criteria set); QueryByCriteria query = QueryFactory.newQuery(RcioDB.class, crit); System.out.println(query created); Object theRcioToBeFetched = broker.getObjectByQuery(query); System.out.println(after fetch); System.out.println(theRcioToBeFetched.getClass()); return (RcioDB)theRcioToBeFetched; } catch (Throwable t) { t.printStackTrace(); throw new DataStoreException(t.toString()); } finally { broker.close(); } This is the output from the log: criteria set query created [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback was called, do rollback on current connection [EMAIL PROTECTED] org.apache.ojb.broker.PersistenceBrokerException: java.lang.ClassCastException at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1467) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1496) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1485) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQ uery(Persistenc eBrokerImpl.java:1747) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObj ectByQuery(Dele gatingPersistenceBroker.java:271) at mil.army.forscom.tsamsweb.rcio.database.RcioCRUD.retrieveRcio (RcioCRUD.java: 131) at mil.army.forscom.tsamsweb.rcio.tests.InsertRciosTest.testInse
How to alternate Criteria.addGroupBy .
Hi all, Today, I noticed that Criteria.addGroupBy is deprcated. Then javadoc use Query#addGroupBy . But, interface org.apache.ojb.broker.query.Query dosen't have addGroupBy method. What do I have to use? -- shivaken antshell: Ant command line front end http://www.antshell.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible OJB Bug with Oracle
Hi Thomas, just to understand, if repository.xml is wrongly configured it shouldn't work with mysql, hsqldb as well not oracle. basically the same file (the platform attribute changes respectivly) works fine for mysql, hsqldb, but not for oracle !!! all java classes are the same in each case, and the underlying java class has an int !! so I would appreciate some further hints !! with best wishes Kristian Mahler Thomas wrote: Hi Kristian, For me this does not look like a OJB bug, but as a configuration problem. If you have a java attribute of type String but have defined it as INTEGER in the repository.xml you've got a problem! If you want to have a String attribute converted into an Oracle Number column you should use a FieldConversion but not change the PlatformOracleImpl. cheers, thomas -Original Message- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 9:46 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle Hello, when I yesterday switch to oracle I came across the same exception and I investigated a bit, and found an unexpected situation in the PlatformOracleImpl.java in the setObjectForStatement( ) method the sqlType was Type.INTEGER and the value was a String class both arguments were passed to the PlatformDefaultImpl.java where they were passed into the PreparedStatement. the String class seemed to be already wrong at this place, but a simple hack does work fine for me: *** PlatformOracleImpl.javaSun May 4 14:08:14 2003 --- src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Jun 5 09:17:58 2003 *** *** 126,131 --- 126,138 ps.setLong(index, ((Integer) value).intValue()); } + else if (sqlType == Types.INTEGER value instanceof String) + { + // workaround: + ps.setInt(index, Integer.parseInt( (String) value ) ); + } else { + this.logger.debug( using type + sqlType + for class + value.getClass().getName() ++ ( + value + ) ); super.setObjectForStatement(ps, index, value, sqlType); } maybe this also helps to find the real bug !!! with best wishes Kristian Brown, Melonie S. - Contractor wrote: Has anybody else ran into this? This is a big problem for us, and I'm catching a lot of flack since I recommended we use OJB. It appears that OJB is generating a getCollection query even though the code specifies a single object. I'm not sure where to begin debugging, so any assistance would be greatly appreciated. Original Message Subject: [RC3] Works with MySql, Fails with ClassCastException with Oracle Date: Thu, 29 May 2003 11:41:00 -0400 From: Brown, Melonie S. - Contractor [EMAIL PROTECTED] Reply-To: OJB Users List [EMAIL PROTECTED] Newsgroups: gmane.comp.jakarta.ojb.user I have code that works perfectly fine in MySQL but crashes and dies against an Oracle database. I'm getting a java.lang.ClassCastException at GetCollectionByQuery which doesn't make sense since I'm calling broker.getObjectbyQuery. Also, no SQL statements show in the spy.log file. Suggestions would be greatly appreciated. This is the code: public static RcioDB retrieveRcio(RcioDB sRcio) throws DataStoreException { PersistenceBroker broker = GetAccess.getPersistenceBroker(); try { broker.beginTransaction(); Criteria crit = new Criteria(); crit.addEqualTo( Constants.RCIO_ID, String.valueOf(sRcio.getRcio_ID())); System.out.println(criteria set); QueryByCriteria query = QueryFactory.newQuery(RcioDB.class, crit); System.out.println(query created); Object theRcioToBeFetched = broker.getObjectByQuery(query); System.out.println(after fetch); System.out.println(theRcioToBeFetched.getClass()); return (RcioDB)theRcioToBeFetched; } catch (Throwable t) { t.printStackTrace(); throw new DataStoreException(t.toString()); } finally { broker.close(); } This is the output from the log: criteria set query created [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback was called, do rollback on current connection [EMAIL PROTECTED] org.apache.ojb.broker.PersistenceBrokerException: java.lang.ClassCastException at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1467) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1496) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio nByQuery(Persis tenceBrokerImpl.java:1485) at
RE: Possible OJB Bug with Oracle
Hi again, -Original Message- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 11:54 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle Hi Thomas, just to understand, if repository.xml is wrongly configured it shouldn't work with mysql, hsqldb as well not oracle. I don't agree. Oracles datatype NUMBER is something completely different than the INTEGER type on MySql or Hsqldb! Oracle NUMBER expects a BigInt on the java side. If you want something different you definitely need a FielConversion. cheers, Thomas basically the same file (the platform attribute changes respectivly) works fine for mysql, hsqldb, but not for oracle !!! all java classes are the same in each case, and the underlying java class has an int !! so I would appreciate some further hints !! with best wishes Kristian Mahler Thomas wrote: Hi Kristian, For me this does not look like a OJB bug, but as a configuration problem. If you have a java attribute of type String but have defined it as INTEGER in the repository.xml you've got a problem! If you want to have a String attribute converted into an Oracle Number column you should use a FieldConversion but not change the PlatformOracleImpl. cheers, thomas -Original Message- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 9:46 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle Hello, when I yesterday switch to oracle I came across the same exception and I investigated a bit, and found an unexpected situation in the PlatformOracleImpl.java in the setObjectForStatement( ) method the sqlType was Type.INTEGER and the value was a String class both arguments were passed to the PlatformDefaultImpl.java where they were passed into the PreparedStatement. the String class seemed to be already wrong at this place, but a simple hack does work fine for me: *** PlatformOracleImpl.javaSun May 4 14:08:14 2003 --- src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Jun 5 09:17:58 2003 *** *** 126,131 --- 126,138 ps.setLong(index, ((Integer) value).intValue()); } + else if (sqlType == Types.INTEGER value instanceof String) + { + // workaround: + ps.setInt(index, Integer.parseInt( (String) value ) ); + } else { + this.logger.debug( using type + sqlType + for class + value.getClass().getName() ++ ( + value + ) ); super.setObjectForStatement(ps, index, value, sqlType); } maybe this also helps to find the real bug !!! with best wishes Kristian Brown, Melonie S. - Contractor wrote: Has anybody else ran into this? This is a big problem for us, and I'm catching a lot of flack since I recommended we use OJB. It appears that OJB is generating a getCollection query even though the code specifies a single object. I'm not sure where to begin debugging, so any assistance would be greatly appreciated. Original Message Subject: [RC3] Works with MySql, Fails with ClassCastException with Oracle Date: Thu, 29 May 2003 11:41:00 -0400 From: Brown, Melonie S. - Contractor [EMAIL PROTECTED] Reply-To: OJB Users List [EMAIL PROTECTED] Newsgroups: gmane.comp.jakarta.ojb.user I have code that works perfectly fine in MySQL but crashes and dies against an Oracle database. I'm getting a java.lang.ClassCastException at GetCollectionByQuery which doesn't make sense since I'm calling broker.getObjectbyQuery. Also, no SQL statements show in the spy.log file. Suggestions would be greatly appreciated. This is the code: public static RcioDB retrieveRcio(RcioDB sRcio) throws DataStoreException { PersistenceBroker broker = GetAccess.getPersistenceBroker(); try { broker.beginTransaction(); Criteria crit = new Criteria(); crit.addEqualTo( Constants.RCIO_ID, String.valueOf(sRcio.getRcio_ID())); System.out.println(criteria set); QueryByCriteria query = QueryFactory.newQuery(RcioDB.class, crit); System.out.println(query created); Object theRcioToBeFetched = broker.getObjectByQuery(query); System.out.println(after fetch); System.out.println(theRcioToBeFetched.getClass()); return (RcioDB)theRcioToBeFetched; } catch (Throwable t) { t.printStackTrace(); throw new DataStoreException(t.toString()); } finally
RE: How to alternate Criteria.addGroupBy .
Just have a a look at the Javadocs: http://db.apache.org/ojb/api/org/apache/ojb/broker/query/QueryByCriteria.htm l#addOrderBy(java.lang.String) Thomas -Original Message- From: shivaken [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 11:21 AM To: OJB Users List Subject: How to alternate Criteria.addGroupBy . Hi all, Today, I noticed that Criteria.addGroupBy is deprcated. Then javadoc use Query#addGroupBy . But, interface org.apache.ojb.broker.query.Query dosen't have addGroupBy method. What do I have to use? -- shivaken antshell: Ant command line front end http://www.antshell.org - 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]
Nested Query, Subquery
Hello Again :), is it possible to use nested queries in OJB OQL ? something like : select distinct struct (code: c.crse_code, title: c.crse_title, (select x from c.offers x where x.enrollment 20)) from courses c or define to classes or more in From statements? thank you. -- Best regards, Alexander mailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to configure OJB with Tomcat
I read the documentation about setting up OJB in a servlet. However I couldnt find any instructions on how to configure connection pooling (eg using jakarta-commons) together with OJB in Tomcat so that connections to the database is pooled. Are there any synchronization issues to be careful about ? Can anyone point me to the right doc, or help me out with example tomcat descriptors and client code ? Thanks ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[4]: ODMG intialization.
Hello Armin, OJB 1 Rc3, I use Oracle, and I've tried both driver ( thin and oci8 ). result the same, when I set repository_database.xml connection-pool maxActive=10 maxIdle=-1 maxWait=3 minEvictableIdleTimeMillis=4 numTestsPerEvictionRun=5 testOnBorrow=true testOnReturn=true testWhileIdle=true timeBetweenEvictionRunsMillis=6 whenExhaustedAction=2 logAbandoned=true whenExhaustedAction = 2, it's works...not completely but works, so I think that problem with non closed connection. AW sounds strange! Could you give some more information. AW Code snip, OJB version, repository_database.xml AW file. -- Best regards, Alexandermailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to alternate Criteria.addGroupBy .
Hi Thomas, Thanks for your advice. But, addGroupBy() accepts Field (name or FieldDescriptor). I want use group by like below, (with mysql) --- select DATE_FORMAT(DATE, %Y %m %d), count(*) from A0 group by DATE_FORMAT(DATE, %Y %m %d) --- The type of DATE is TIMESTAMP. Is there any way ? On Thursday 05 June 2003 18:57, Mahler Thomas wrote: Just have a a look at the Javadocs: http://db.apache.org/ojb/api/org/apache/ojb/broker/query/QueryByCriteria.ht m l#addOrderBy(java.lang.String) Thomas -- -- shivaken antshell: Ant command line front end http://www.antshell.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Identity_Insert mssql
Did you ever solve this? I'm having the same issue with Sybase 11.9.3 identity columns. Peter Costa [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am stuck with it for right now. So I take it there is no easy way around this other than removing the Identities. If anyone has any suggestions it would be much appreciated. I am pretty much stuck right now. Thank you. Peter -Original Message- From: Ryan Vanderwerf [mailto:[EMAIL PROTECTED] Sent: Wed 4/9/2003 5:27 PM To: OJB Users List Cc: Subject: RE: Identity_Insert mssql Personally I'd remove use of identities where you can, and use the SequenceManangerStoredProcedureImpl class, it will use a stored procedure instead which is multi-app server safe (and tested on mssql). It's in current cvs, I'm guessing it will be in next rc3 release. That identity stuff isn't worth it, if you are stuck with them then my condolences ;) Ryan -Original Message- From: Peter Costa [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 09, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: Identity_Insert mssql We are using OJB and mssql. We are having problems with tables that have an identity field on the which allows for auto-incrementing. I have been told that it was fixed in 1.0, but when we tried it we still had issues. Does anyone know about this issue? Do I need to change something in one of the xml files? Any help would be appreciated. Thank you. Peter - 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: Identity_Insert mssql
We were not able to fix it. We had to modify the OJB code to check to see if the first field is an auto-increment field and if it was, then we would turn Identity insert on. That requires that you make sure that if you are going to use Identity insert that it be the first field. Not a great fix, but it seems to be working right now. It is a hack, but we don't have time to deal with it. Hope this helps. Peter -Original Message- From: Brian Chaplin [mailto:[EMAIL PROTECTED] Sent: Thu 6/5/2003 9:52 PM To: [EMAIL PROTECTED] Cc: Subject: Re: Identity_Insert mssql Did you ever solve this? I'm having the same issue with Sybase 11.9.3 identity columns. Peter Costa [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am stuck with it for right now. So I take it there is no easy way around this other than removing the Identities. If anyone has any suggestions it would be much appreciated. I am pretty much stuck right now. Thank you. Peter -Original Message- From: Ryan Vanderwerf [mailto:[EMAIL PROTECTED] Sent: Wed 4/9/2003 5:27 PM To: OJB Users List Cc: Subject: RE: Identity_Insert mssql Personally I'd remove use of identities where you can, and use the SequenceManangerStoredProcedureImpl class, it will use a stored procedure instead which is multi-app server safe (and tested on mssql). It's in current cvs, I'm guessing it will be in next rc3 release. That identity stuff isn't worth it, if you are stuck with them then my condolences ;) Ryan -Original Message- From: Peter Costa [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 09, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: Identity_Insert mssql We are using OJB and mssql. We are having problems with tables that have an identity field on the which allows for auto-incrementing. I have been told that it was fixed in 1.0, but when we tried it we still had issues. Does anyone know about this issue? Do I need to change something in one of the xml files? Any help would be appreciated. Thank you. Peter - 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 delete a referenced object AND the object
Hello, I have a Workstation class which contains the attribute wntWorkstationId and the reference wntWorkstation to another class WntWorkstation (there is a 1:1 relationship). How could I delete in Workstation the reference wntWorkstation (the attribute wntWorksationId) AND the referenced entry in WntWorksation?? Thanks Sylvain - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Access to proc on a IBM mainfraime
I saw in the doc that OJB ships with full JTA and JCA Integration. What means this. -Message d'origine- De : Mahler Thomas [mailto:[EMAIL PROTECTED] Envoyé : mercredi 4 juin 2003 13:16 À : 'OJB Users List' Objet : RE: Access to proc on a IBM mainfraime Hi there, OJB is meant an O/R toll *above* a java JDBC database connection. There is currently no support for any other backends like the CICS Gateway for Java, etc. cheers, thomas -Original Message- From: PETRINI Claude [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 11:54 AM To: [EMAIL PROTECTED] Subject: Access to proc on a IBM mainfraime We have programs Cobol CICS on a mainfraime IBM which reach a DB2 database. We reach these COBOL programs through a Java proxy which returns a collection of beans. Can I use OJB to reach these Cobol programs. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDO QL query question
I have an object field called registrationDate defined using a java.util.Date object in my JDO, and it is stored in my database as a TIMESTAMP. Now, I wish to make queries like finding all objects which registrationDate is later than a perticular value. I tried using a filter and using the operator, but I guess this only works for primitives, or maybe I have to implement a comparable in my JDO class ? How is the proper JDO way of doing this ? Thanks for suggestions ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Storing objects creates exception: no such attribute a0.version
Hi, I am currently upgrading from ver 0.9.8 to ver 1.0 rc3. I used to be able to store objects with no problems but am now having problems with getting the identifiers generated from org.apache.ojb.broker.util.sequence.HighLowSequence. It keeps on giving me an ERROR: No such attribute a0.version when I try to store. I used this org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl class with no problems at all in version 0.9.8. Now the only thing that works is org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl. My question is why and what is the difference between these two sequence managers. Cheers Paula The operation I perform is as follows: try { // Set author Author author = new Author(); author.setAuthor(name); author.setEmailAddress(emailAddress); // Add comment to vector Vector commentVector = author.getCommentVector(); commentVector.addElement(comment); author.setCommentVector(commentVector); ObjectModificationDefaultImpl objectMod = new ObjectModificationDefaultImpl(true, false); broker.beginTransaction(); broker.store(author, objectMod); broker.commitTransaction(); } catch (Exception e) { e.printStackTrace(); broker.abortTransaction(); return false; } The repostitory_database.xml extract is: sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl attribute attribute-name=grabSize attribute-value=20/ attribute attribute-name=autoNaming attribute-value=true/ attribute attribute-name=globalSequenceId attribute-value=false/ attribute attribute-name=globalSequenceStart attribute-value=1/ /sequence-manager The stack trace and logfile I get is as follows with org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl: 36107 DEBUG [Thread-4] accesslayer.ConnectionManagerImpl - Try to change autoCommit state to 'false' 36107 DEBUG [Thread-4] cache.ObjectCacheFactory - Object cache created, using cache:[EMAIL PROTECTED] CACHE STATISTICS Count of temporarily cached objects=0 ] 36107 DEBUG [Thread-4] sequence.SequenceManagerFactory - create new sequence manager for broker [EMAIL PROTECTED] 36107 DEBUG [Thread-4] sequence.SequenceManagerFactory - Jdbc-Connection-Descriptor 'postgres' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl 36123 DEBUG [Thread-4] accesslayer.ConnectionFactoryPooledImpl - makeObject called 36138 DEBUG [Thread-4] accesslayer.ConnectionManagerImpl - Request new connection from ConnectionFactory: [EMAIL PROTECTED] 36138 DEBUG [Thread-4] accesslayer.ConnectionManagerImpl - Try to change autoCommit state to 'false' 36154 DEBUG [Thread-4] core.PersistenceBrokerImpl - getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class org.apache.ojb.broker.util.sequence.HighLowSequence, Query from class org.apache.ojb.broker.util.sequence.HighLowSequence where [EMAIL PROTECTED]) 36154 DEBUG [Thread-4] core.PersistenceBrokerImpl - Creating RsIterator for class [org.apache.ojb.broker.util.sequence.HighLowSequence] 36154 DEBUG [Thread-4] accesslayer.JdbcAccessImpl - executeQuery : Query from class org.apache.ojb.broker.util.sequence.HighLowSequence where [EMAIL PROTECTED] 36154 DEBUG [Thread-4] sql.SqlGeneratorDefaultImpl - SQL:SELECT A0.VERSION,A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE ? ) AND A0.FIELDNAME LIKE ? 36169 ERROR [Thread-4] accesslayer.JdbcAccessImpl - SQLException during the execution of the query (for a org.apache.ojb.broker.util.sequence.HighLowSequence): ERROR: No such attribute a0.version java.sql.SQLException: ERROR: No such attribute a0.version at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131) at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection .java:505) at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.j ava:320) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.j ava:48) at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statem ent.java:153) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.init(Unknown Source) at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Unkn own Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Unknow n Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknow n Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknow n Source) at
Cache inconsitence using deleteByQuery with PersistenceBrokerImpl
Hello, I noticed an odd behaviour when using *broker.deleteByQuery*, this issue seems to be known (see developer mailist, msg 652 [VOTE] deleteByQuery leaves Cache in an inconsistent state), however no info is still available in the javadoc nor a solution seems to be available. Get a look at this code: broker = PersistenceBrokerFactory.defaultPersistenceBroker(); //Insert entries try { broker.beginTransaction(); UserAttrs ua; //Columns:userid, attrName, attrValue //Primary Key: x ,x ua= new UserAttrs( id1, attr1, test1 ); broker.store( ua ); ua= new UserAttrs( id1, attr2, test2 ); broker.store( ua ); broker.commitTransaction(); } catch (Throwable t) { broker.abortTransaction(); t.printStackTrace(); } //Delete all entries with userID = id1 try { UserAttrs ua= new UserAttrs(); ua.setUserid( id1 ); Query q = new QueryByCriteria(ua); broker.beginTransaction(); broker.deleteByQuery( q ); broker.commitTransaction(); } catch (Throwable t) { broker.abortTransaction(); t.printStackTrace(); } //Re-Insert entries try { broker.beginTransaction(); UserAttrs ua; //Columns:userid, attrName, attrValue //Primary Key: x ,x ua= new UserAttrs( id1, attr1, test1 ); broker.store( ua ); ua= new UserAttrs( id1, attr2, test2 ); broker.store( ua ); broker.commitTransaction(); } catch (Throwable t) { broker.abortTransaction(); t.printStackTrace(); } On first execution this causes the generation of following SQL: SELECT ATTR_NAME,USERID,ATTR_VALUE FROM USER_ATTRS WHERE USERID = 'id1' AND ATTR_NAME = 'attr1' INSERT INTO USER_ATTRS (USERID,ATTR_NAME,ATTR_VALUE) VALUES ('id1','attr1','test1') SELECT ATTR_NAME,USERID,ATTR_VALUE FROM USER_ATTRS WHERE USERID = 'id1' AND ATTR_NAME = 'attr2' INSERT INTO USER_ATTRS (USERID,ATTR_NAME,ATTR_VALUE) VALUES ('id1','attr2','test2') - commit SELECT A0.ATTR_NAME,A0.USERID,A0.ATTR_VALUE FROM USER_ATTRS A0 WHERE A0.USERID = 'id1' DELETE FROM USER_ATTRS WHERE USERID = 'id1' - commit SELECT ATTR_NAME,USERID,ATTR_VALUE FROM USER_ATTRS WHERE USERID = 'id1' AND ATTR_NAME = 'attr1' UPDATE USER_ATTRS SET ATTR_VALUE='test1' WHERE USERID = 'id1' AND ATTR_NAME = 'attr1' SELECT ATTR_NAME,USERID,ATTR_VALUE FROM USER_ATTRS WHERE USERID = 'id1' AND ATTR_NAME = 'attr2' UPDATE USER_ATTRS SET ATTR_VALUE='test2' WHERE USERID = 'id1' AND ATTR_NAME = 'attr2' - commit The UPDATE statements in the 3. block will have no effect on the database, this is from my point of view a seldom but potentially dangerous BUG!!! There is a simple workaround to this, until the code is fixed, simply call a broker.clearCache() after the deleteByQuery transaction has been executed. However this is a performance killer if you are going to deleteByQuery very often. I adopted following solution, but since I am a OJB Newbie I'd like to know if you see a better solution, without re-implementing the ObjectCacheImpl class I extended PersistenceBrokerImpl through a new class and did an override of the deleteByQuery method, then declared this new class in the OJB.properties int the PersistenceBrokerClass property. Here the code: public class SafeDeleteByQueryPBImpl extends PersistenceBrokerImpl { protected SafeDeleteByQueryPBImpl() { super(); } public SafeDeleteByQueryPBImpl(PBKey key, PersistenceBrokerFactoryIF pbf) { super( key, pbf ); } /** * Bug workaround * Added code for clearing matching objects from cache when executing PersistenceBrokerImpl.deleteByQuery(query) * @see org.apache.ojb.broker.PersistenceBroker#deleteByQuery(Query) */ public void deleteByQuery(Query query) throws PersistenceBrokerException { //Clear cached objects Iterator it= super.getIteratorByQuery( query ); //List all objects affected by the query while ( it.hasNext() ) { super.objectCache.remove( new Identity( it.next(), this ) );//Remove matching objects form cache } //Delegate deleteByQuery to super class super.deleteByQuery( query ); } } Calling the method will cause an extra SELECT statment to be inserted and all the objects to be loaded in memory, however this should be faster than executing single deletes or clearing the cache each time. Is there a better solution to that? Thanks and sorry for the long message Danilo Tommasina - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
WebSphere server, ODMG
Hello , Maybe someone already got such problem. I've wrote app using WebSphere and Oracle. Using servlet, i store object, if I try to get it in this session ( without restarting of the server, I got nothing). when I restart server - I can use Query for load object, but then I am not be able to store it :). each time, when I store or load object I execute such code: odmg = OJB.getInstance(); Database db = odmg.newDatabase(); String dataBaseDefName = buildDefDatabase(); //open database try { //db.open(REPOSITORY_FILE, Database.OPEN_READ_WRITE); db.open(dataBaseDefName, Database.OPEN_READ_WRITE); } catch (ODMGException ex) { } maybe problem there? If I use standalone application, all works fine. thank you. -- Best regards, Alexander mailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OJB will not persist a simple object :-(
Thanks so much Armin. Now After writing one object to the db, I get no errros but no more objects written to the database. DEBUG tells me it is now updating an object rather than doing a new insert even though a new object is attempted to be written. My repository.xml has changed to this: jdbc-connection-descriptor jcd-alias=mysql default-connection=true platform=MySQL jdbc-level=3.0 driver=org.gjt.mm.mysql.Driver protocol=jdbc subprotocol=mysql dbalias=//127.0.0.1/wolfbot username=wolfbot password=wb0t eager-release=false batch-mode=true useAutoCommit=2 ignoreAutoCommitExceptions=true connection-pool maxActive=10 maxIdle=2 maxWait=3 whenExhaustedAction=2 / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl/ /jdbc-connection-descriptor Thanks again, Chuck - Original Message - From: Armin Waibel [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 5:00 AM Subject: Re: OJB will not persist a simple object :-( Hi Chuck, - Original Message - From: Chuck Grohowski [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 7:09 AM Subject: OJB will not persist a simple object :-( Hello I successfully have OJB 0.9.9 working in a web app and am trying to get OJB 1.0rc3 working correctly in a standalone app I am developing. When trying to persist a simple object all that is returned in the log is this : [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO: Destroy object was called, try to close connection: [EMAIL PROTECTED] This is called by the commons-pool api when a corrupted connection was found (asking the pool for a connection) or commons-pool shrink the connection-pool and destory(close) idle connections. eager-release=true It's recommended to set 'eager-release' false (introduced only for use OJB within jboss). logAbandoned=true detection of abandoned connections only supported by ConnectionFactoryDBCPImpl implementation (before use, please get latest version from CVS - was refactored). All other ConnectionFactory implementations ignore these properties. regards, Armin Any help would be appreciated. No exceptions are being thrown so I really don't know where to start looking. :( My database is mysql Ver 12.20 Distrib 4.0.13, for pc-linux (i686) TIA, Chuck Grohowski repository.xml: ?xml version=1.0 encoding=UTF-8? !-- This is a sample metadata repository for the ObJectBridge System. Use this file as a template for building your own mappings-- !-- defining entities for include-files -- !DOCTYPE descriptor-repository SYSTEM repository.dtd [ !ENTITY user SYSTEM repository_user.xml !ENTITY internal SYSTEM repository_internal.xml ] descriptor-repository version=1.0 isolation-level=read-uncommitted !-- The Default JDBC Connection. If a class-descriptor does not specify its own JDBC Connection, the Connection specified here will be used. -- jdbc-connection-descriptor jcd-alias=mysql default-connection=true platform=MySQL jdbc-level=3.0 driver=org.gjt.mm.mysql.Driver protocol=jdbc subprotocol=mysql dbalias=//127.0.0.1/wolfbot username=wolfbot password= eager-release=true batch-mode=true useAutoCommit=2 ignoreAutoCommitExceptions=true connection-pool maxActive=10 maxIdle=2 maxWait=3 minEvictableIdleTimeMillis=4 numTestsPerEvictionRun=5 testOnBorrow=true testOnReturn=true testWhileIdle=true timeBetweenEvictionRunsMillis=6 whenExhaustedAction=2 validationQuery=select * from test limit 0,1 logAbandoned=true removeAbandoned=true removeAbandonedTimeout=8 / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl / /jdbc-connection-descriptor !-- include user defined mappings here -- user; !-- include ojb internal mappings here -- internal; /descriptor-repository repository_user.xml: class-descriptor class=Kills table=kills field-descriptor name=idcolumn=id jdbc-type=INTEGER nullable=false primarykey=true autoincrement=true/ field-descriptor name=prawner column=prawner jdbc-type=INTEGER nullable=false/ field-descriptor name=prawned column=prawned jdbc-type=INTEGER nullable=false/ field-descriptor name=deathBy column=death_by jdbc-type=INTEGER nullable=false/ field-descriptor name=timeOfDeath column=time_of_death jdbc-type=TIME nullable=false/ /class-descriptor offending code: public static void recordKill( Kills k ) { PersistenceBroker broker = null; try { broker = PersistenceBrokerFactory.defaultPersistenceBroker(); broker.beginTransaction(); broker.store( k ); broker.commitTransaction(); } catch( PBFactoryException pbe ) {
Re: OJB will not persist a simple object :-(
Hi Chuck, to isolate your problem use default settings for connection properties: eager-release=false batch-mode=false useAutoCommit=1 ignoreAutoCommitExceptions=false Maybe the sequence manager cause the problem. Change the sequence manager (e.g. SequenceManagerInMemoryImpl when running in non-clustered environment) if possible. regards, Armin - Original Message - From: Chuck Grohowski [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 5:30 PM Subject: Re: OJB will not persist a simple object :-( Thanks so much Armin. Now After writing one object to the db, I get no errros but no more objects written to the database. DEBUG tells me it is now updating an object rather than doing a new insert even though a new object is attempted to be written. My repository.xml has changed to this: jdbc-connection-descriptor jcd-alias=mysql default-connection=true platform=MySQL jdbc-level=3.0 driver=org.gjt.mm.mysql.Driver protocol=jdbc subprotocol=mysql dbalias=//127.0.0.1/wolfbot username=wolfbot password=wb0t eager-release=false batch-mode=true useAutoCommit=2 ignoreAutoCommitExceptions=true connection-pool maxActive=10 maxIdle=2 maxWait=3 whenExhaustedAction=2 / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl / /jdbc-connection-descriptor Thanks again, Chuck - Original Message - From: Armin Waibel [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 5:00 AM Subject: Re: OJB will not persist a simple object :-( Hi Chuck, - Original Message - From: Chuck Grohowski [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 7:09 AM Subject: OJB will not persist a simple object :-( Hello I successfully have OJB 0.9.9 working in a web app and am trying to get OJB 1.0rc3 working correctly in a standalone app I am developing. When trying to persist a simple object all that is returned in the log is this : [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO: Destroy object was called, try to close connection: [EMAIL PROTECTED] This is called by the commons-pool api when a corrupted connection was found (asking the pool for a connection) or commons-pool shrink the connection-pool and destory(close) idle connections. eager-release=true It's recommended to set 'eager-release' false (introduced only for use OJB within jboss). logAbandoned=true detection of abandoned connections only supported by ConnectionFactoryDBCPImpl implementation (before use, please get latest version from CVS - was refactored). All other ConnectionFactory implementations ignore these properties. regards, Armin Any help would be appreciated. No exceptions are being thrown so I really don't know where to start looking. :( My database is mysql Ver 12.20 Distrib 4.0.13, for pc-linux (i686) TIA, Chuck Grohowski repository.xml: ?xml version=1.0 encoding=UTF-8? !-- This is a sample metadata repository for the ObJectBridge System. Use this file as a template for building your own mappings-- !-- defining entities for include-files -- !DOCTYPE descriptor-repository SYSTEM repository.dtd [ !ENTITY user SYSTEM repository_user.xml !ENTITY internal SYSTEM repository_internal.xml ] descriptor-repository version=1.0 isolation-level=read-uncommitted !-- The Default JDBC Connection. If a class-descriptor does not specify its own JDBC Connection, the Connection specified here will be used. -- jdbc-connection-descriptor jcd-alias=mysql default-connection=true platform=MySQL jdbc-level=3.0 driver=org.gjt.mm.mysql.Driver protocol=jdbc subprotocol=mysql dbalias=//127.0.0.1/wolfbot username=wolfbot password= eager-release=true batch-mode=true useAutoCommit=2 ignoreAutoCommitExceptions=true connection-pool maxActive=10 maxIdle=2 maxWait=3 minEvictableIdleTimeMillis=4 numTestsPerEvictionRun=5 testOnBorrow=true testOnReturn=true testWhileIdle=true timeBetweenEvictionRunsMillis=6 whenExhaustedAction=2 validationQuery=select * from test limit 0,1 logAbandoned=true removeAbandoned=true removeAbandonedTimeout=8 / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl / /jdbc-connection-descriptor !-- include user defined mappings here -- user; !-- include ojb internal mappings here -- internal; /descriptor-repository repository_user.xml: class-descriptor class=Kills table=kills field-descriptor name=idcolumn=id jdbc-type=INTEGER nullable=false primarykey=true autoincrement=true/ field-descriptor name=prawner column=prawner jdbc-type=INTEGER nullable=false/
Problems with DMap
Hi, I'm having problems with TransactionImpl.markDelete(Object anObject) regarding keys to DMAP entries as well as the DMap Impl object itself. markDelete will sometimes not cause an sql DELETE for these objects at transaction commit. However, the Entry object always get deleted. The persistent key class contains a pk field and a string value field. The equals and hashCode methods are overridden to implement value-based equality on the string value field only, thus ignoring the pk field. I discovered this problem with markDelete sometime earlier and worked around it by dropping down to the lower layer with sql = DELETE FROM OJB_DMAP WHERE ID = + ((DMapImpl)object).getId() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; sql = DELETE FROM PSTRING WHERE ID = + ((PersistentString)object).getID() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE) regarding persistent string keys and persistent string values. lock will sometimes not cause an sql INSERT at transaction commit. The map entry objects get inserted by the string keya and values do not. I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values. the TransactionImpl.put method only locks the key and value for REEAD. I have verified the actual generated sql via the postgresql log. Can anybody help? Thanks in advance, Mark
Looking for guidelines ...
I installed OJB and ran the junit tests. Then I decided to make a test with a helloworld flavored application. I used the great xdoclet-ojb tool (this package is findable in the OJB CVS contrib) to generate myapp-repository.xml and myapp-schema.xml directly from my java source code (neat!). But I spent almost a day trying to figure out how to compile everything (myapp) in directories that are different from the ojbtest project ones. Torque complains, lots of things complains and time flies. Is anyone aware of guidelines explaining the directory structures and how to complie a project different from the test project ? I found the Ojb documentation very usefull so far, but on this point : explanation of the directory structure and its algebra through ant properties, I think some guidlines would be great! Thanks for your help, Elie
App server-specific startup class needed?
What are the reasons for writing startup classes (ODMGFactory and PBFactory) specific to an app server (extending jboss.ServiceMBeanSupport for JBoss, and extending T3StartupDef for WebLogic, and xxx for WebSphere)? Could this be achieved using JMX alone, or does the spec not meet the needs to initialize the OJB factory classes and bind them to JNDI? The reason for asking is we are trying to support multiple app servers, and avoid coding to specific vendors/versions where possible. Thanks, Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
refreshing a connection
A requirement for my application is that the application can continue to service requests even if the database connection is severed. In order to do this, i'm putting insert requests into a queue and pushing them back on if they fail. What i'm finding tho is that the if the db is started and stopped that the ojb connection pool does not refresh itself nor can i force the pool to replace the connection with a new one. Am i missing something? I'm using mssql server if that matters. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
optimistic locking question
Forgive me, I know this is a really basic question, but... I just finished reading how to set up optimistic locking. I gather that I need to set this explicitly for each class, and that each table needs to have a dedicated column for this purpose (timestamp or integer). Is this correct? Is there anything written on optimistic locking besides the info found in http://db.apache.org/ojb/repository.html#field-descriptor? thanks, Bonnie MacKellar software engineer Mobius Management Systems, Inc. [EMAIL PROTECTED]
Re: Database views
Hi Raymond, Raymond Barlow wrote: Hi all, I'd like to get a general opinion on what is the best practise for using database views or not. I'm currently converting a system that has a number of views. Some of the views use other views to build up reporting type information. I would think that in a totally clean class driven environment views would be bad, as the tables should only be used for persistence. If views are bad, how do you build up the same sort of thing using OJB/persistant classes? ie. where there were views using views, what is the equivalent way of thinking in OJB? What would you generally do here? If you do not want to use database views you can use OJB report queries to perform arbitrary queries and present the result as a view. But why not use database views and map them to view-classes. I think this can be a good solution in certain cases. just my 2c, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with DMap
Hi Mark, can you post a piece of code demonstrating the failure? I'd like to verify this with a test case. cheers, thomas Mark Neighbors wrote: Hi, I'm having problems with TransactionImpl.markDelete(Object anObject) regarding keys to DMAP entries as well as the DMap Impl object itself. markDelete will sometimes not cause an sql DELETE for these objects at transaction commit. However, the Entry object always get deleted. The persistent key class contains a pk field and a string value field. The equals and hashCode methods are overridden to implement value-based equality on the string value field only, thus ignoring the pk field. I discovered this problem with markDelete sometime earlier and worked around it by dropping down to the lower layer with sql = DELETE FROM OJB_DMAP WHERE ID = + ((DMapImpl)object).getId() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; sql = DELETE FROM PSTRING WHERE ID = + ((PersistentString)object).getID() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE) regarding persistent string keys and persistent string values. lock will sometimes not cause an sql INSERT at transaction commit. The map entry objects get inserted by the string keya and values do not. I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values. the TransactionImpl.put method only locks the key and value for REEAD. I have verified the actual generated sql via the postgresql log. Can anybody help? Thanks in advance, Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1-M mappings retry
Hi I just wanted to reping the group on this questions I am having trouble performing tasks with a 1-M mapping None of my objects use the reference descritor constructs. I constructed my 1-M exactly as the documentation suggests but the problem that i have is that when my test attempts to add a new child object (adjustmentTO) to the order (orderTO) it does not work. i basically read the orderTO from the database, add a new AdjustmentTO object to the adjustments collection and try to store. It does not store the adjustment despite having auto-update set to true. However, if i call store on both the order and the adjustment, then the order is updated and the adjustment is created. is this how it is supposed to function or am i missing something ? thanks J James Nyika Cambridge Technology Partners The global eServices company of Novell, Inc. http://www.novell.com [EMAIL PROTECTED] 5/31/2003 3:23:19 PM Hi Is the reference-descriptor in a 1-M mapping requried for a proper 1-M mapping ? I have an OrderTO object that can hold a collection of AdjustmentTO objects here is my descriptor mapping (notice, no reference mapping in the child class) descriptor start--- class-descriptor class=com.anasi.application.feecalculation.entities.OrderTO table=ORDER field-descriptor name=id column=ID jdbc-type=INTEGER conversion=org.apache.ojb.broker.accesslayer.conversions.Int2IntegerFieldConversion primarykey=true autoincrement=true/ field-descriptor name=orderState column=ORDERSTATE jdbc-type=INTEGER/ field-descriptor name=payerId column=PAYER_ID jdbc-type=BIGINT/ field-descriptor name=payeeId column=PAYEE_ID jdbc-type=BIGINT/ field-descriptor name=orderAmount column=ORDERAMOUNT jdbc-type=DOUBLE precision=5 scale=2/ field-descriptor name=orderDate column=ORDERDATE jdbc-type=DATE conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion/ collection-descriptor name=adjustments element-class-ref=com.anasi.application.feecalculation.entities.AdjustmentTO orderby=entryDate sort=DESC auto-retrieve=true auto-update=true auto-delete=true refresh=true inverse-foreignkey field-ref=orderId/ /collection-descriptor /class-descriptor class-descriptor class=com.anasi.application.feecalculation.entities.AdjustmentTO table=ADJUSTMENT field-descriptor name=id column=ID jdbc-type=INTEGER conversion=org.apache.ojb.broker.accesslayer.conversions.Int2IntegerFieldConversion primarykey=true autoincrement=true/ field-descriptor name=reasonId column=REASON_ID jdbc-type=BIGINT/ field-descriptor name=orderId column=ORDER_ID jdbc-type=INTEGER/ field-descriptor name=typeId column=TYPE_ID jdbc-type=BIGINT/ field-descriptor name=authCodeId column=AUTH_CODE_ID jdbc-type=BIGINT/ field-descriptor name=amount column=AMOUNT jdbc-type=DOUBLE scale=2/ field-descriptor name=entryDate column=ENTRY_DATE jdbc-type=DATE conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion/ field-descriptor name=effectiveDate column=EFFECTIVE_DATE jdbc-type=DATE conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion/ field-descriptor name=expirationDate column=EXPIRATION_DATE jdbc-type=DATE conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion/ /class-descriptor descriptor end--- AdjustmentTO objects are only written to the database when the Collection actually contains any AdjustmentTO objects the first time i create the order. All subsequent attempts to add one more AdjustmentTO object to the vector and store is not working. When i re-read the OrderTO object i simply get back the same objects that were created the first time - no more no less. is this a mapping problem ? Why is that reference descriptor required ? thanks James Nyika Cambridge Technology Partners The global eServices company of Novell, Inc. http://www.novell.com - 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 DMap
I can't send the actual code. Duplicating the error in an autonomous test may be probematic. It could be due to some mechanism (mine or ojb's) that doesn't get repesented in the autonomous environment. The only other alternatives I can think of at this point are to attempt working around it with pb operations, and to write a variation of DMap that stores the string key directly in the map entry table. And so since I'm under the gun at this point I need to decide which avenue to take. I'm leaning toward attempting to avoid the problem by getting rid of persistent strings as keys/values. However this won't avoid the problem of deleting the OJB_DMAP row, which will probably still need to be done with the pb. If I can't work around it I'll attempt to duplicate the error. - Original Message - From: Thomas Mahler [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 2:37 PM Subject: Re: Problems with DMap Hi Mark, can you post a piece of code demonstrating the failure? I'd like to verify this with a test case. cheers, thomas Mark Neighbors wrote: Hi, I'm having problems with TransactionImpl.markDelete(Object anObject) regarding keys to DMAP entries as well as the DMap Impl object itself. markDelete will sometimes not cause an sql DELETE for these objects at transaction commit. However, the Entry object always get deleted. The persistent key class contains a pk field and a string value field. The equals and hashCode methods are overridden to implement value-based equality on the string value field only, thus ignoring the pk field. I discovered this problem with markDelete sometime earlier and worked around it by dropping down to the lower layer with sql = DELETE FROM OJB_DMAP WHERE ID = + ((DMapImpl)object).getId() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; sql = DELETE FROM PSTRING WHERE ID = + ((PersistentString)object).getID() ; persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ; Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE) regarding persistent string keys and persistent string values. lock will sometimes not cause an sql INSERT at transaction commit. The map entry objects get inserted by the string keya and values do not. I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values. the TransactionImpl.put method only locks the key and value for REEAD. I have verified the actual generated sql via the postgresql log. Can anybody help? Thanks in advance, Mark - 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]
1 n Maps
Hi, I am having some misunderstandings on implementing 1,n mappings. The mapping is this one, as follows right bellow. My doubt is in the collectin-descriptor: What is the field that I need to reference on the inverse-foreignkey? This colection is a vector of EntidadeExternaPessoaContato, and this field _idPessoaContato does not seem right to me. Can anyone point me what is the right way to think about this problem? Best regards, Marcelo Magno class-descriptor class=dom.EntidadeExterna table=EntidadeExterna field-descriptor name=_idEntidadeExterna column=PkEntidadeExterna jdbc-type=INTEGER primarykey=true autoincrement=true / field-descriptor name=_nome column=Nome jdbc-type=VARCHAR / collection-descriptor name=_listaPessoaContato element-class-ref=dom.EntidadeExternaPessoaContato auto-retrieve=true auto-update=true inverse-foreignkey field-ref=_idPessoaContato/ !-- from EntidadeExternaPessoaContato ???-- /collection-descriptor /class-descriptor class-descriptor class=dom.EntidadeExternaPessoaContato table=EntidadeExternaPessoaContato field-descriptor name=_idPessoaContato column=PkEntidadeExternaPessoaContato jdbc-type=INTEGER primarykey=true autoincrement=true / field-descriptor name=_nome column=Nome jdbc-type=VARCHAR / field-descriptor name=_telefone column=Telefone jdbc-type=VARCHAR / field-descriptor name=_email column=Email jdbc-type=VARCHAR / field-descriptor name=_unidadeId column=FkUnidade jdbc-type=INTEGER / reference-descriptor name=_unidade class-ref=dom.Unidade foreignkey field-ref=_unidadeId/ /reference-descriptor /class-descriptor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SequenceManager trouble with rc3
I'm having some problems moving from 0.9.8 in the SequenceManager. I have a polymorphic class ObservationValue_ that has multiple extent-class. I have a primary key valueId which I try to increment with the call broker.serviceSequenceManager().getUniqueValue(field); This call fails with a NullPointerExdeption. It works in another case where the class isn't polymorphic. I had a work around in 0.9.8 to handle this case: /** try { // work around problem in OJB 0.9.8 ClassDescriptor cld = broker.getClassDescriptor(clazz); if ( (cld.isAbstract() || cld.isInterface()) cld.isExtent()) clazz = (Class)cld.getExtentClasses().get(0); return broker.getUniqueId(clazz, fieldName); } catch (org.apache.ojb.broker.PersistenceBrokerException e) { cat.error(Can't get ID from broker: + clazz.getName() + + fieldName, e); // System.exit(1); return 0; } */ but I thought this should have been fixed. The method getUniqueId isn't any more. I did make a change along the lines above to redefine clazz and it seems to work. Is this the way I should do it, or am I missing a new call somewhere? Here is a segment of my repository_user.xml file: !-- Class description for all classes implementing gov.lanl.COAS.ObservationValue_ class-descriptor class=gov.lanl.COAS.ObservationValue_ extent-class class-ref=gov.lanl.COAS.Multimedia_/ extent-class class-ref=gov.lanl.COAS.NoInformation_/ extent-class class-ref=gov.lanl.COAS.Numeric_/ extent-class class-ref=gov.lanl.COAS.ObservationId_/ extent-class class-ref=gov.lanl.COAS.QualifiedCodeInfo_/ extent-class class-ref=gov.lanl.COAS.QualifiedPersonId_/ extent-class class-ref=gov.lanl.COAS.Range_/ extent-class class-ref=gov.lanl.COAS.String_/ extent-class class-ref=gov.lanl.COAS.TimeSpan_/ extent-class class-ref=gov.lanl.COAS.UniversalResourceIdentifier_/ extent-class class-ref=gov.lanl.COAS.Empty_/ /class-descriptor class-descriptor class=gov.lanl.COAS.String_ table=OjbString_ isolation-level=read-uncommitted field-descriptor id=1 name=valueId jdbc-type=INTEGER column=valueId primarykey=true / field-descriptor id=2 name=string jdbc-type=LONGVARCHAR column=String / /class-descriptor David W. Forslund [EMAIL PROTECTED] Computer and Computational Sciences http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 505-663-5218FAX: 505-663-5225
mySQL Sequences
I'm working with mySQL 4+ and OJB's current release. I am wondering about the preferred method for autoincrement keys in mySQL. Almost all of my tables have an integer ID field that autoincrements in mySQL. I also edit the databases directly (i.e. not through OJB) through other apps. When I use the default sequence manager, it requires an OJB_HL_SEQ table, and key generation gets a little sloppy when adding or deleting from outside OJB. Here's what I'd like to use: 1) A sequence manager that will use mySQL's built in keying. In other words, I'd like to set the ID field of my (new) object to null, then store the record, and then check to see what ID it got. 2) A sequence manager that does not need additional tables to operate. I sometimes deal with situations where I have only SELECT, UPDATE, DELETE access on the tables I'm utilizing... and I cannot create new tables for OJB to utilize. The documentation seems to suggest that there is a solution to these issues, but I can't find examples to try out. So far though, I love the convenience of OJB. Great work! Thanks, Aaron Longwell - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ODMG intialization.
Hello , I can't find answer for this question... But I have a some strange trouble and it looks like I didn't close connections. ( I also call db.close() after each operations ). Should I call another finalized methods? thank you. From: Mauricio CASTRO [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Saturday, May 24, 2003, 10:30:52 PM If I am using ODMG in a multithreaded application. Should I call for each thread the following code? Implementation instance = OJB.getInstance(); Database db = instance.newDatabase(); //open database db.open(dbName, Database.OPEN_READ_WRITE); odmg.set(instance); Or I just call db.open(...) the first time? It's is possible to share db among the different threads? Should I close something at any time, apart committing/aborting transactions? -- Best regards, Alexander mailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]