Trying to get OJB up and running (newbie)
Hi there I am trying to learn how to use OJB. At the moment I am not getting very far. Either I have not installed something correctly, or I have not configured something correctly. When I call the db.open method I get a mass of exceptions. Perhaps someone can see where I can start looking for the problem... Here is a snippet of my code: Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); try { db.open( databaseName, Database.OPEN_READ_WRITE ); } And here is the first part of some output I see (which comes from inside the open method): [org.apache.ojb.broker.metadata.ConnectionRepository] INFO: Could not found org.apache.ojb.broker.metadata.JdbcConnectionDescriptor for PBKey org.apache.ojb.broker.PBKey: repository=C:/Work/Experimentation/OJB/repository.xml, user=null, password=null [org.apache.ojb.broker.accesslayer.ConnectionManagerFactory] ERROR: ConfigurableFactory instantiation failed for class class org.apache.ojb.broker.accesslayer.ConnectionManagerImpl * Factory types: 1 - Type: org.apache.ojb.broker.PersistenceBroker * Factory arguments: 1 - Argument: [EMAIL PROTECTED] null java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at org.apache.ojb.broker.platforms.PlatformFactory.getPlatformFor(Unknown Source) at org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.init(Unknown Source) at java.lang.reflect.Constructor.newInstance(Native Method) at org.apache.ojb.broker.util.ClassHelper.newInstance(Unknown Source) at org.apache.ojb.broker.util.factory.ConfigurableFactory.createNewInstance(Unk nown Source) at org.apache.ojb.broker.util.factory.ConfigurableFactory.createNewInstance(Unk nown Source) at org.apache.ojb.broker.accesslayer.ConnectionManagerFactory.createConnectionM anager(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.init(Unknown Source) at java.lang.reflect.Constructor.newInstance(Native Method) at org.apache.ojb.broker.util.ClassHelper.newInstance(Unknown Source) at org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.createNewBroker Instance(Unknown Source) at org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl$PBKeyedPoolable ObjectFactory.makeObject(Unknown Source) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeye dObjectPool.java:748) at org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.createPersisten ceBroker(Unknown Source) at org.apache.ojb.broker.PersistenceBrokerFactory.createPersistenceBroker(Unkno wn Source) at org.apache.ojb.odmg.DatabaseImpl.open(Unknown Source) at dk.pk.ojb.Test.main(Test.java:103) Thanks for any help, Peter
Sybase: JZ0BE: BatchUpdateException -- symbol table overflow
Hello, I am using OJB with Sybase 11.5 ASE, JConnect 5.5. I have a problem that might be specific to sybase, but maybe someone can help me. I have an application that writes some objects into the database. When I write 30 objects, it works, but when I write 35, it fails with the appended exception. The class has a lot of attributes. Maybe there is a size limitation in sybase. Is there a way to fix/bypass that problem in OJB? Olli --- com.sybase.jdbc2.jdbc.SybBatchUpdateException: JZ0BE: BatchUpdateException: Fehler beim Ausführen einer Batch-Anweisung: Too many parameters -- symbol table overflow. at com.sybase.jdbc2.jdbc.ErrorMessage.raiseBatchUpdateException(ErrorMessage.ja va:802) at com.sybase.jdbc2.jdbc.SybStatement.batchLoop(SybStatement.java:1329) at com.sybase.jdbc2.jdbc.SybStatement.sendBatch(SybStatement.java:1138) at com.sybase.jdbc2.jdbc.SybStatement.executeBatch(SybStatement.java:1105) at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeBatch(SybPreparedStatement .java:768) at org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.doExecut e(PreparedStatementInvocationHandler.java:197) at org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.invoke(P reparedStatementInvocationHandler.java:140) at $Proxy0.doExecute(Unknown Source) at org.apache.ojb.broker.util.batch.BatchConnection.executeBatch(BatchConnectio n.java:287) at org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.executeBatch(Connect ionManagerImpl.java:326) at org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:190) at org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(TransactionImpl.java:3 26) at org.apache.ojb.odmg.TransactionImpl.prepare(TransactionImpl.java:575) at org.apache.ojb.odmg.TransactionImpl.commit(TransactionImpl.java:525) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Query builder for OJB
Hello, Is anyone that use OJB know something about a query builder that could create a query automatically based on several criteria? Thanks Sylvain - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cache confusion
I find that I'm just not understanding how the cache works, or the proper way to work with it. I use the ODMG api in a web application. I thought I had read here on the email list that the cache was used within a transaction but that it was cleared after the transaction ended. But I found that some of my dropdown boxes were not being updated because they were being pulled from the cache, eventhough they were being retreived within a separate transaction. This was unexpected. So I switched to using the ObjectCacheEmptyImpl until I understood caching better. But *even* *then* I found that objects were not always refreshed from the database. This was *totally* unexpected. I finally had to put a broker.clearCache() just after opening my transactions in order to guarantee that I actually pulled from the database. Clearly, I'm not doing or understanding something properly. I've read the cache html docs, but perhaps someone could talk about the cache and how to work with it successfully. Thanks, Will - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
R: cache confusion
So I switched to using the ObjectCacheEmptyImpl until I understood caching better. But *even* *then* I found that objects were not always refreshed from the database. This was *totally* unexpected. I finally had to put a broker.clearCache() just after opening my transactions in order to guarantee that I actually pulled from the database. I have exactly the same problem, and I had to flush the cache manually as you did. Could someone explain this strange behaviour? Thanks in advance - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Trying to get OJB up and running (newbie)
Hello Peter, -Original Message- From: Peter Kirk [mailto:[EMAIL PROTECTED] When I call the db.open method I get a mass of exceptions. Perhaps someone can see where I can start looking for the problem... this might be a known problem. (See thread: Help : OJB, ODMG API !) Get the newest tutorial2 Application.java from http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/tutorial2/ Here is a snippet of my code: Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); try { db.open( databaseName, Database.OPEN_READ_WRITE ); } And here is the first part of some output I see (which comes from inside the open method): [org.apache.ojb.broker.metadata.ConnectionRepository] INFO: Could not found org.apache.ojb.broker.metadata.JdbcConnectionDescriptor for PBKey org.apache.ojb.broker.PBKey: repository=C:/Work/Experimentation/OJB/repository.xml, user=null, You have edited that value, haven't you? It's meaning is not the repository file any more, but a reference to an alias inside it. Olli - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Trying to get OJB up and running (newbie)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 10. marts 2003 14:37 To: [EMAIL PROTECTED] Subject: RE: Trying to get OJB up and running (newbie) And here is the first part of some output I see (which comes from inside the open method): [org.apache.ojb.broker.metadata.ConnectionRepository] INFO: Could not found org.apache.ojb.broker.metadata.JdbcConnectionDescriptor for PBKey org.apache.ojb.broker.PBKey: repository=C:/Work/Experimentation/OJB/repository.xml, user=null, You have edited that value, haven't you? It's meaning is not the repository file any more, but a reference to an alias inside it. Yes, I couldn't get the tutorial2 to work at all. So I have been trying to set up my own simple (really simple) application. It seems that the tutorial stuff has extra things defined in the xml files (junit tests and such?). Anyway it seemed a little confusing to me. I just wanted a dead simple first try - a hypersonic database with a single table, a single dataclass with a single text string as data... Also, I couldn't run the build batch file succesfully - here I get errors (and a huge exception/stack trace). Peter
RE: Reference descriptor woes
snip There was a reason for this design. Say there is an abstract class A and a concrete class B extending A. No say there is a B instance b with a primary key value '17'. If we do not use the toplevel extent to define Identies it could happen that OJB addresses this object as A{17} or as B{17}. this result would violate base rules like if x == y then id(x) == id(y) snip I'm confused...Why do you rely on == instead of .equals? As application developers, we have to correctly implement .equals and .hashCode() to guarantee identity when using Java 2 Collections. What is the reason for using the address identity in OJB? The reason I ask is I have a similar scenario, a base class of Foo with two derived classes Foo_current and Foo_history used to store to an active table or a historical table. Foo_active is an empty class and history maintains some additional dates. In some cases, I want to access all Foo's, regardless of active or history, but need efficient access to the active Foo's when explicitly referenced. Currently, when I access the Foo_active, OJB will search all Foo_active and Foo_history (which is rather large) to find the object resulting in very slow response times. Any advise? Wally - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Trying to get OJB up and running (newbie)
Hello Peter, -Original Message- From: Peter Kirk [mailto:[EMAIL PROTECTED] It seems that the tutorial stuff has extra things defined in the xml files (junit tests and such?). Anyway it seemed a little confusing to me. I just wanted a dead simple first try - a hypersonic database with a single table, a single dataclass with a single text string as data... I definetly agree that the out-of-the-box experience of OJB is a weak point. I suffered, too, when I tried to get a simple isolated example to start with. There are some threads in this list about that topic. Also, I couldn't run the build batch file succesfully - here I get errors (and a huge exception/stack trace). Which errors? Olli - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Trying to get OJB up and running (newbie)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 10. marts 2003 16:23 To: [EMAIL PROTECTED] Subject: RE: Trying to get OJB up and running (newbie) Hello Peter, -Original Message- From: Peter Kirk [mailto:[EMAIL PROTECTED] Also, I couldn't run the build batch file succesfully - here I get errors (and a huge exception/stack trace). Which errors? Hi, below is some of the output I see in my windows dos prompt (I've snipped a bit away because it's quite long): Buildfile: build.xml set-archive-name: set-archive-name-date: detect-jdk: check-jdk12proxy-classes: check-jndi-classes: use-jdk12: use-jdk13: [echo] detected JDK 1.3 use-jdk14: init: prepare: check-j2ee-classes: preprocess: [echo] using switches: +JDK13, -JDBC30 [java] .. snip project-create-db-classpath: [echo] [echo] driver=org.hsqldb.jdbcDriver [echo] url=jdbc:hsqldb:target/test/OJB [echo] userid=sa [echo] password= [echo] [torque-create-db] Using classpath [torque-create-db] Generating to file C:\FILE DOWNLOADS\Java\OJB\rc1\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1\ target\src\sql\create-db.sql [torque-create-db] Resolver: used database.dtd from org.apache.torque.engine.database.transform package [torque-create-db] Resolver: used database.dtd from org.apache.torque.engine.database.transform package [sql] Executing file: C:\FILE DOWNLOADS\Java\OJB\rc1\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1\ target\src\sql\create-db.sql [sql] 0 of 1 SQL statements executed successfully snip project-insert-sql: [torque-insert-sql] Our new url - jdbc:hsqldb:target/test/OJB [torque-insert-sql] Executing file: C:\FILE DOWNLOADS\Java\OJB\rc1\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1\ target\src\sql\ojbtest-schema.sql [torque-insert-sql] Executing file: C:\FILE DOWNLOADS\Java\OJB\rc1\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1\ target\src\sql\ojbcore-schema.sql [torque-insert-sql] Executing file: C:\FILE DOWNLOADS\Java\OJB\rc1\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1-src\db-ojb-1.0.rc1\ target\src\sql\ojbtest-data.sql [torque-insert-sql] 231 of 231 SQL statements executed successfully junit-no-compile-no-prepare: [junit] Running org.apache.ojb.broker.AllTests [junit] Tests run: 187, Failures: 2, Errors: 182, Time elapsed: 16,624 sec [junit] Running org.apache.ojb.odmg.AllTests [junit] [BOOT] INFO: OJB.properties: file:/C:/FILE DOWNLOADS/Java/OJB/rc1/db-ojb-1.0.rc1-src/db-ojb-1.0.rc1-src/db-ojb-1.0.rc1/ target/test/ojb/OJB.properties [junit] [BOOT] ERROR: Error in instantiation of PersistenceBrokerFactory class [junit] Could not read repository class descriptor data, using repository: repository.xml: no protocol: repository.dtd [junit] java.net.MalformedURLException: no protocol: repository.dtd [junit] at java.net.URL.init(URL.java:473) [junit] at java.net.URL.init(URL.java:376) [junit] at java.net.URL.init(URL.java:330) [junit] at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) [junit] at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) [junit] at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) [junit] at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) [junit] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [junit] at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) [junit] at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) [junit] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [junit] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [junit] at org.apache.ojb.broker.metadata.RepositoryPersistor.buildRepository(Repositor yPersistor.java:288) [junit] at org.apache.ojb.broker.metadata.RepositoryPersistor.readDescriptorRepository( RepositoryPersistor.java:199) [junit] at org.apache.ojb.broker.metadata.MetadataManager.init(MetadataManager.java:88) [junit] at org.apache.ojb.broker.metadata.MetadataManager.init(MetadataManager.java:7 9) [junit] at org.apache.ojb.broker.metadata.MetadataManager.getInstance(MetadataManager.j ava:113) [junit] at org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.buildDefaultKey (PersistenceBrokerFactoryDefaultImpl.java:145) [junit] at org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.init(Persiste nceBrokerFactoryDefaultImpl.java:116) [junit] at java.lang.Class.newInstance0(Native Method) [junit] at java.lang.Class.newInstance(Class.java:237) [junit] at org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory.instantiate(Persist enceBrokerFactoryFactory.java:99) [junit] at
RE: HSQL Timestamp sql exception illegal format
Hi, Try this in your file repository_user_hsql.xml: conversion=org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFi eldConversion in the field-descriptor block. Laurent -Original Message- From: Stefan Schlösser [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 16:21 To: oJB Users List Subject: HSQL Timestamp sql exception illegal format Hi, when a try insert something into a HSQL DB with a timestamp I get a java.sql.SQLException: Wrong data type: Timestamp format must be - mm-dd hh:mm:ss.f Swifting through the docs brought mew to the conclusion that my timestamp is declared as a java.util.date in the object to be stored and HSQL seems to expect a java.sql.Date object. Is there a way to let ojb handle this, or do I need to write a specialised repository_user_hsql.xml to contain hsql specific conversion routines? My coding works fine when connecting to a SAPDB. What to do ? Cheers, Stefan - 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: Xdcolet support
Bad typing morning. Of course I meant XDoclet. |-Original Message- |From: Ebersole, Steven [mailto:[EMAIL PROTECTED] |Sent: Monday, March 10, 2003 10:51 AM |To: OJB Users List (E-mail) |Subject: Xdcolet support | | |Are there currently any plans for XDcolet support in OJB |for mapping |generation? | | |Steve Ebersole |IT Integration Engineer |Vignette Corporation |Office: 512.741.4195 |Mobile: 512.297.5438 | |Visit http://www.vignette.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: Xdcolet support
i have some xdoclet support sitting in a changelist. I am becoming more and more busy with other stuff and haven't had time to finish it yet. I will be flying quite a bit near the end of this week and will try to finish it then. maybe someone out there would like to help? -Original Message- From: Ebersole, Steven [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 8:52 AM To: 'OJB Users List' Subject: RE: Xdcolet support Bad typing morning. Of course I meant XDoclet. |-Original Message- |From: Ebersole, Steven [mailto:[EMAIL PROTECTED] |Sent: Monday, March 10, 2003 10:51 AM |To: OJB Users List (E-mail) |Subject: Xdcolet support | | |Are there currently any plans for XDcolet support in OJB |for mapping |generation? | | |Steve Ebersole |IT Integration Engineer |Vignette Corporation |Office: 512.741.4195 |Mobile: 512.297.5438 | |Visit http://www.vignette.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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reference descriptor woes
Hi Wally, I think you are right. If the developer implements .equals() and .hashCode() and OJB keys the objects on the hashCode then there should be no reason why we would need to travel up the hierarchy chain. It adds a bit more complexity to the inheritance implementation on the user's side, but the optimization, I think, is worth it. What do OJB gurus think? --Bill. - Original Message - From: Gelhar, Wallace J. [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Monday, March 10, 2003 6:57 AM Subject: RE: Reference descriptor woes snip There was a reason for this design. Say there is an abstract class A and a concrete class B extending A. No say there is a B instance b with a primary key value '17'. If we do not use the toplevel extent to define Identies it could happen that OJB addresses this object as A{17} or as B{17}. this result would violate base rules like if x == y then id(x) == id(y) snip I'm confused...Why do you rely on == instead of .equals? As application developers, we have to correctly implement .equals and .hashCode() to guarantee identity when using Java 2 Collections. What is the reason for using the address identity in OJB? The reason I ask is I have a similar scenario, a base class of Foo with two derived classes Foo_current and Foo_history used to store to an active table or a historical table. Foo_active is an empty class and history maintains some additional dates. In some cases, I want to access all Foo's, regardless of active or history, but need efficient access to the active Foo's when explicitly referenced. Currently, when I access the Foo_active, OJB will search all Foo_active and Foo_history (which is rather large) to find the object resulting in very slow response times. Any advise? Wally - 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]
ConnectionRepository
Hello everybody! I am a newbie and try to implement a little application by using ojb. Now: I get an error message when I try to run my app: As I see, the error comes up in the ConnectionRepository.class in the getDescriptor(PBKey pbKey) method, where the jcdMap.get(pgKey) returns a NULL result instead of a valid hashtable. I set the repositoryFile in the OJB.properties to the path of repository.xml and it's subrepositories (as f.e. repository_database.xml). What am I doing wrong? Thanks! Christian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Xdcolet support
I've never done any xdoclet api programming, but I'd be willing to help out if you gave me a few simple pointers and examples. I have looked at the xdoclet stuff for hibernate a little, so hopefully I could pick it up quickly. From what I have understood, it is mainly defining the .xdt files. Correct? |-Original Message- |From: Matthew Baird [mailto:[EMAIL PROTECTED] |Sent: Monday, March 10, 2003 11:07 AM |To: OJB Users List |Subject: RE: Xdcolet support | | |i have some xdoclet support sitting in a changelist. | |I am becoming more and more busy with other stuff and |haven't had time to finish it yet. | |I will be flying quite a bit near the end of this week and |will try to finish it then. | |maybe someone out there would like to help? | |-Original Message- |From: Ebersole, Steven [mailto:[EMAIL PROTECTED] |Sent: Monday, March 10, 2003 8:52 AM |To: 'OJB Users List' |Subject: RE: Xdcolet support | | |Bad typing morning. Of course I meant XDoclet. | | | ||-Original Message- ||From: Ebersole, Steven [mailto:[EMAIL PROTECTED] ||Sent: Monday, March 10, 2003 10:51 AM ||To: OJB Users List (E-mail) ||Subject: Xdcolet support || || ||Are there currently any plans for XDcolet support in OJB ||for mapping ||generation? || || ||Steve Ebersole ||IT Integration Engineer ||Vignette Corporation ||Office: 512.741.4195 ||Mobile: 512.297.5438 || ||Visit http://www.vignette.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] | | |--- |-- |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: HAVING clause
hi all, i just commited the first try to support HAVING clause. this sample code with a having-criteria: ReportQueryByCriteria query; Criteria crit, having; crit = new Criteria(); crit.addGroupBy(new String[] { id, name, vorname }); having = new Criteria(); having.addGreaterThan(sum(konti.saldo), new Integer(200)); query = new ReportQueryByCriteria(Person.class, crit); query.setColumns(new String[] { id, name, vorname, sum(konti.saldo) }); query.setHavingCriteria(having); broker.getReportQueryIteratorByQuery(query);; produces this sql: SELECT A0.id,A0.name,A0.vorname,sum(A1.saldo) FROM tabPerson A0 INNER JOIN tabKonto A1 ON A0.id=A1.idPerson GROUP BY A0.id,A0.name,A0.vorname HAVING sum(A1.saldo) '200' do not expect this first version to work perfectly ! there will be problems when the whereCriteria is empty but the havingCriteria not. hth jakob David Mitchell wrote: Is there some particular reason why there's no addHaving() method on Criteria? I needed to do the following query on my database. (I am implementing an INTERSECTION query, which isnt supported by my database, SQL Server) SELECT numOperators FROM flFactoryOperatorCycleTime WHERE (workCenterNdx = 64) AND (productNdx IN (753, 754, 758)) GROUP BY numOperators HAVING (COUNT(*) = 3) Since I needed to only query a single field (numOperators) and could not deal with selecting ALL columns (due to the group by clause), I used a report query . So far so good. Then, I ran into trouble because report queries can only be created from Criteria, which don't seem to support HAVING clauses. My hack (which works) to get around it is to FAKE it! But I do wish I had a better solution. Criteria crit = new Criteria(); crit.addEqualTo(IFactoryOperatorCycleTime.WORKCENTERNDX, new Integer(((IPersistentObject)workCenter).getNdx())); crit.addIn(IFactoryOperatorCycleTime.PRODUCTNDX, productNdxs); crit.addSql((1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = +productNdxs.size()+)); The reason for the (1=1) is because when you do an addSql() on a criteria, it helpfully puts in the 'AND' part for you, but AND HAVING... doesnt work, and HAVING has to come after the GROUP BY, so if I do the addGroupBy() method separately, the HAVING gets put BEFORE the GROUP BY, which also doesnt work. The final query ends up looking like this: SELECT A0.numOperators FROM flFactoryOperatorCycleTime A0 WHERE (( A0.workCenterNdx = ? ) AND (A0.productNdx IN ( ? , ? , ? ))) AND (1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = 3) Any better suggestions? thanks- David Mitchell +-+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +-+ - 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: HAVING clause
Cool! Just curious, can you elaborate a little as to why you felt that the Having clause should go in query as opposed to in criteria? -dave -Original Message- From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 2:43 PM To: OJB Users List Subject: Re: HAVING clause hi all, i just commited the first try to support HAVING clause. this sample code with a having-criteria: ReportQueryByCriteria query; Criteria crit, having; crit = new Criteria(); crit.addGroupBy(new String[] { id, name, vorname }); having = new Criteria(); having.addGreaterThan(sum(konti.saldo), new Integer(200)); query = new ReportQueryByCriteria(Person.class, crit); query.setColumns(new String[] { id, name, vorname, sum(konti.saldo) }); query.setHavingCriteria(having); broker.getReportQueryIteratorByQuery(query);; produces this sql: SELECT A0.id,A0.name,A0.vorname,sum(A1.saldo) FROM tabPerson A0 INNER JOIN tabKonto A1 ON A0.id=A1.idPerson GROUP BY A0.id,A0.name,A0.vorname HAVING sum(A1.saldo) '200' do not expect this first version to work perfectly ! there will be problems when the whereCriteria is empty but the havingCriteria not. hth jakob David Mitchell wrote: Is there some particular reason why there's no addHaving() method on Criteria? I needed to do the following query on my database. (I am implementing an INTERSECTION query, which isnt supported by my database, SQL Server) SELECT numOperators FROM flFactoryOperatorCycleTime WHERE (workCenterNdx = 64) AND (productNdx IN (753, 754, 758)) GROUP BY numOperators HAVING (COUNT(*) = 3) Since I needed to only query a single field (numOperators) and could not deal with selecting ALL columns (due to the group by clause), I used a report query . So far so good. Then, I ran into trouble because report queries can only be created from Criteria, which don't seem to support HAVING clauses. My hack (which works) to get around it is to FAKE it! But I do wish I had a better solution. Criteria crit = new Criteria(); crit.addEqualTo(IFactoryOperatorCycleTime.WORKCENTERNDX, new Integer(((IPersistentObject)workCenter).getNdx())); crit.addIn(IFactoryOperatorCycleTime.PRODUCTNDX, productNdxs); crit.addSql((1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = +productNdxs.size()+)); The reason for the (1=1) is because when you do an addSql() on a criteria, it helpfully puts in the 'AND' part for you, but AND HAVING... doesnt work, and HAVING has to come after the GROUP BY, so if I do the addGroupBy() method separately, the HAVING gets put BEFORE the GROUP BY, which also doesnt work. The final query ends up looking like this: SELECT A0.numOperators FROM flFactoryOperatorCycleTime A0 WHERE (( A0.workCenterNdx = ? ) AND (A0.productNdx IN ( ? , ? , ? ))) AND (1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = 3) Any better suggestions? thanks- David Mitchell +-+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +-+ - 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] +-+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HAVING clause
hi david, because there's only one having in a query. when adding having to the criteria it would be possible to have multiple havings. the same is also true for groupby / orderby which are currently located at the criteria. and it's imo not very intuitive to add a having criteria to a where-criteria. jakob David Mitchell wrote: Cool! Just curious, can you elaborate a little as to why you felt that the Having clause should go in query as opposed to in criteria? -dave -Original Message- From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 2:43 PM To: OJB Users List Subject: Re: HAVING clause hi all, i just commited the first try to support HAVING clause. this sample code with a having-criteria: ReportQueryByCriteria query; Criteria crit, having; crit = new Criteria(); crit.addGroupBy(new String[] { id, name, vorname }); having = new Criteria(); having.addGreaterThan(sum(konti.saldo), new Integer(200)); query = new ReportQueryByCriteria(Person.class, crit); query.setColumns(new String[] { id, name, vorname, sum(konti.saldo) }); query.setHavingCriteria(having); broker.getReportQueryIteratorByQuery(query);; produces this sql: SELECT A0.id,A0.name,A0.vorname,sum(A1.saldo) FROM tabPerson A0 INNER JOIN tabKonto A1 ON A0.id=A1.idPerson GROUP BY A0.id,A0.name,A0.vorname HAVING sum(A1.saldo) '200' do not expect this first version to work perfectly ! there will be problems when the whereCriteria is empty but the havingCriteria not. hth jakob David Mitchell wrote: Is there some particular reason why there's no addHaving() method on Criteria? I needed to do the following query on my database. (I am implementing an INTERSECTION query, which isnt supported by my database, SQL Server) SELECT numOperators FROM flFactoryOperatorCycleTime WHERE (workCenterNdx = 64) AND (productNdx IN (753, 754, 758)) GROUP BY numOperators HAVING (COUNT(*) = 3) Since I needed to only query a single field (numOperators) and could not deal with selecting ALL columns (due to the group by clause), I used a report query . So far so good. Then, I ran into trouble because report queries can only be created from Criteria, which don't seem to support HAVING clauses. My hack (which works) to get around it is to FAKE it! But I do wish I had a better solution. Criteria crit = new Criteria(); crit.addEqualTo(IFactoryOperatorCycleTime.WORKCENTERNDX, new Integer(((IPersistentObject)workCenter).getNdx())); crit.addIn(IFactoryOperatorCycleTime.PRODUCTNDX, productNdxs); crit.addSql((1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = +productNdxs.size()+)); The reason for the (1=1) is because when you do an addSql() on a criteria, it helpfully puts in the 'AND' part for you, but AND HAVING... doesnt work, and HAVING has to come after the GROUP BY, so if I do the addGroupBy() method separately, the HAVING gets put BEFORE the GROUP BY, which also doesnt work. The final query ends up looking like this: SELECT A0.numOperators FROM flFactoryOperatorCycleTime A0 WHERE (( A0.workCenterNdx = ? ) AND (A0.productNdx IN ( ? , ? , ? ))) AND (1=1) GROUP BY NUMOPERATORS HAVING (COUNT(*) = 3) Any better suggestions? thanks- David Mitchell +-+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +-+ - 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] +-+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL
Re: Reference descriptor woes
Hi Wally, Gelhar, Wallace J. wrote: snip There was a reason for this design. Say there is an abstract class A and a concrete class B extending A. No say there is a B instance b with a primary key value '17'. If we do not use the toplevel extent to define Identies it could happen that OJB addresses this object as A{17} or as B{17}. this result would violate base rules like if x == y then id(x) == id(y) snip I'm confused...Why do you rely on == instead of .equals? As application developers, we have to correctly implement .equals and .hashCode() to guarantee identity when using Java 2 Collections. What is the reason for using the address identity in OJB? I was unprecise I meant if (x.equals(y) then id(x).equals(y) Of course OJB checks equality and not address identity! The reason I ask is I have a similar scenario, a base class of Foo with two derived classes Foo_current and Foo_history used to store to an active table or a historical table. Foo_active is an empty class and history maintains some additional dates. In some cases, I want to access all Foo's, regardless of active or history, but need efficient access to the active Foo's when explicitly referenced. Currently, when I access the Foo_active, OJB will search all Foo_active and Foo_history (which is rather large) to find the object resulting in very slow response times. Any advise? I always thought that this was possible! Maybe we have a code regression here. We'll have to check this issue. For the time being you could manipulate the extent descriptor at runtime to achieve different query behaviour. cheers, Thomas Wally - 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: HSQL Timestamp sql exception illegal format
See http://db.apache.org/ojb/jdbc-types.html You can use the JavaDate2SqlDate FieldConversion for this task cheers, Thomas Stefan Schlösser wrote: Hi, when a try insert something into a HSQL DB with a timestamp I get a java.sql.SQLException: Wrong data type: Timestamp format must be - mm-dd hh:mm:ss.f Swifting through the docs brought mew to the conclusion that my timestamp is declared as a java.util.date in the object to be stored and HSQL seems to expect a java.sql.Date object. Is there a way to let ojb handle this, or do I need to write a specialised repository_user_hsql.xml to contain hsql specific conversion routines? My coding works fine when connecting to a SAPDB. What to do ? Cheers, Stefan - 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: A better way to manage m:n relations ?
If you want that level of control, why don't you create an object for your indirection table? Because I like the conceptual idea of non-decomposed relations as implemented in OJB. I mean, when you have designed your high-level domain objects model, you do not think about these relationtable type of objects that only consist of two foreign keys. Your domain objects when mapped to Java simply have collections of other objects, and the model is high-level and simple to draw. But when the database grows much bigger and I look at the actual database statements, and the resulting performance implications, I get the feeling that it does not scale well. Maybe you are absolutely right, and using an actual object is a better solution. But then what is the value of the OJB implementation ? Anyone actually using it for non-trivial size database ? Thanks for your reply, Theo -Original Message - From: Gelhar, Wallace J. [mailto:[EMAIL PROTECTED] Sent: maandag 10 maart 2003 18:11 To: OJB Users List Subject: RE: A better way to manage m:n relations ? If you want that level of control, why don't you create an object for your indirection table? Wally -Original Message- From: Theo Niemeijer [mailto:[EMAIL PROTECTED] Sent: Monday, March 10, 2003 10:59 AM To: OJB Users List Subject: A better way to manage m:n relations ? Hi all. Something that still bothers me when using OJB is the way I have to manage my non-decomposed m:n relationships. Because the indirection tabel is not directly accessible as domain objects, I have to fill a vector with references to the related objects, and then do a store on the main object. OJB will then delete all the n:m relation entries for that object in the indirection tabel, and then recreate them from the collection. (As far as i can see using the P6spy and the sources) I would think it would be easier and more efficient if there would be a method link that would insert a relation, and a method unlink that would remove a relationship. Without such methods I will always have unneccessary store actions on the main object. [Note that I am only using the Perstince Broker, not the higher level API's] An alternative would be to use a collection that would implement this under its covers, so it would do link and unlink via its interface methods add(Object), addAll(Collection), remove(Object) removeAll(Collection). Is there anyone out there using n:m collections that found a way to avoid these redundant stores and deleta activities ? Regards, Theo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reference descriptor woes
Hi Bill, I don't know if I qualify as OJB guru, but I have some thoughts here. From a java point of view it would be easy to identify objects on a .equals() and .hashCode() basis. But OJB must also maintain object identity accross several JVMs and one or more RDBMS. IMO there is no other way than the existing Identity concept to deal with it. (As I mentioned in an other mail already the rule should go if x.equals(y) then id(x).equals(id(y) and also very important: if (! id(x).equals(id(y))) then (! x.equals(y)) ) But we will have to check if there is a bug in situations where you are performing queries against a concrete class and not the top-level class. cheers, Thomas V.B. Skrypnyk wrote: Hi Wally, I think you are right. If the developer implements .equals() and .hashCode() and OJB keys the objects on the hashCode then there should be no reason why we would need to travel up the hierarchy chain. It adds a bit more complexity to the inheritance implementation on the user's side, but the optimization, I think, is worth it. What do OJB gurus think? --Bill. - Original Message - From: Gelhar, Wallace J. [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Monday, March 10, 2003 6:57 AM Subject: RE: Reference descriptor woes snip There was a reason for this design. Say there is an abstract class A and a concrete class B extending A. No say there is a B instance b with a primary key value '17'. If we do not use the toplevel extent to define Identies it could happen that OJB addresses this object as A{17} or as B{17}. this result would violate base rules like if x == y then id(x) == id(y) snip I'm confused...Why do you rely on == instead of .equals? As application developers, we have to correctly implement .equals and .hashCode() to guarantee identity when using Java 2 Collections. What is the reason for using the address identity in OJB? The reason I ask is I have a similar scenario, a base class of Foo with two derived classes Foo_current and Foo_history used to store to an active table or a historical table. Foo_active is an empty class and history maintains some additional dates. In some cases, I want to access all Foo's, regardless of active or history, but need efficient access to the active Foo's when explicitly referenced. Currently, when I access the Foo_active, OJB will search all Foo_active and Foo_history (which is rather large) to find the object resulting in very slow response times. Any advise? Wally - 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]