Re: How to set null for a column for which the corresponding java type is long
Hi, Do not use a primitive data type in your persistent class, use instead a subtype of Number. (Integer, Long, BigInteger, BigDecimal,... ) cheers Danilo Hi, All I have a data base column. The data type is number (10). It is nullable. The JDBC type defined in repository is BIGINT and the corresponding java type is long (default). Can anybody tell me how to save a record so that the value of that column is null instead of zero? Thanks, Zhe __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ - 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]
Using VerifyMappingTask
Hi, I want to automatically check the integrity of the repository.xml file and the corresponding database-mapping. So I tried out the VerifyMappingTask which is includes in the OJB-distribution (I am using rc5). But I am having problems with the classpath. Here is the situation: - My persistent classes inherit from a class kos.generator.DataObject which is provided in an extra JAR. - I set up the follwing ant-target: target name=verify-schema depends=init taskdef name=verifymappings classname=org.apache.ojb.broker.ant.VerifyMappingsTask classpath refid=project.class.path/ /taskdef path id=verify.classpath pathelement location=${lib}/ojb-generator.jar/ pathelement location=bin/ /path property name=verify.classpath.property refid=verify.classpath/ verifymappings propertiesFile=${conf}/OJB.properties repositoryFile=${conf}/repository.xml jdbcDriver=sun.jdbc.odbc.JdbcOdbcDriver url=jdbc:odbc:kos_db logon=sa password= ignoreFieldNameCase=true useStrictTypeChecking=false verifyclasspath=${verify.classpath.property} useXMLValidation=true failonerror=true/ /target == With these setting the task starts to run cleanly, and it seems to start checking but then it stops with: BUILD FAILED: java.lang.NoClassDefFoundError: kos/generator/DataObject I already tried to change the classpath in some ways, but that doesn't help (I even have the ojb-generator.jar in the ant boot-classpath). Does anyone have an idea what I am doing wrong? Tino - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to set null for a column for which the corresponding java type is long
But isn't that much slower? /me is a newbie in java and ojb On Wed, 28 Jan 2004, Danilo Tommasina wrote: Hi, Do not use a primitive data type in your persistent class, use instead a subtype of Number. (Integer, Long, BigInteger, BigDecimal,... ) cheers Danilo Hi, All I have a data base column. The data type is number (10). It is nullable. The JDBC type defined in repository is BIGINT and the corresponding java type is long (default). Can anybody tell me how to save a record so that the value of that column is null instead of zero? Thanks, Zhe __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ - 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: How to set null for a column for which the corresponding java type is long
Danilo Tommasina wrote: I have a data base column. The data type is number (10). It is nullable. The JDBC type defined in repository is BIGINT and the corresponding java type is long (default). Can anybody tell me how to save a record so that the value of that column is null instead of zero? Do not use a primitive data type in your persistent class, use instead a subtype of Number. (Integer, Long, BigInteger, BigDecimal,... ) Or; if you don't have control over the bean or want to keep long, use a field conversion class that converts long values of 0 as NULL. There are quite a few pre-packaged field conversion classes that come with OJB, they can be found in the package: org.apache.ojb.broker.accesslayer.conversions The Int2IntegerFieldConversion class can be used as a template for how to write a field conversion for a long with 0-inserts as NULL. See http://cvs.apache.org/viewcvs.cgi/*checkout*/db-ojb/src/java/org/apache/ojb/broker/accesslayer/conversions/Int2IntegerFieldConversion.java?content-type=text%2Fplainrev=1.3 To use field conversions, specify them in your repository. Eg: class-descriptor class={x} table={x} field-descriptor name={x} column={x} jdbc-type={x} conversion=com.mycompany.PrimitiveLong2LongFieldConversion/ HTH, Martin -- Martin Kalén Curalia AB Web: http://www.curalia.se Orrspelsvägen 2BMail: [EMAIL PROTECTED] SE-182 79 StocksundTel: +46-8-410 064 40 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Performance difference between mapping number column to long vs BigDecimal
ZZZ Liu wrote: I am trying to know the performance difference between mapping number column to long vs BigDecimal. I did following test. Just as a side note and not a direct answer to your question: the OJB performance will be very dependent on the RDBMS performance, especially when running tight loops with lots of data loading. I.e. your test results will vary a lot depending on which database server your are using, JDBC-driver, indexes and/or clusters in the database etc. etc. For example: you could find that OJB is faster with one column type on MySQL but get the other way around with Oracle (or even different versions on MySQL server). Regards, Martin -- Martin Kalén Curalia AB Web: http://www.curalia.se Orrspelsvägen 2BMail: [EMAIL PROTECTED] SE-182 79 StocksundTel: +46-8-410 064 40 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using VerifyMappingTask
First, you can always invoke ant with the -v option for more information (or even -debug for usually way too much information). Second, I see in the source of the verify task that the classpath option of the task is called 'verifyClassPath' whereas you have 'verifyclasspath' (note the lowercase). Third, you did not write where the kos.generator.DataObject class is located. If its in the ojb-generator.jar file, then you should check whether the classpath works, for instance by using the java task to invoke this class with the same classpath you're using for the verify task. If you still get a NoClassDefFoundError than you have an error in either the jar or the classpath. If you get an error about that there is no main in the class file, then it might be a bug in the verify task itself. If its not in the ojb-generator.jar file, then you should add the jar containing the class explicitly to the classpath. Hope that helps, Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
1:n relationships excessive database calls
Hi, Here's the situation I am faced with.Could anybody analyze the situation and tell me which way to go on this? We have a Person valueobject mapped to a Person table in the database. We have an Application valueobject mapped to the Application table in the database. In the Person valueobject, we've used X-Doclet tags to define an 1:n relationship to Application valueobjects. That is, a person can have 0 or more applications associated with himself. So, the Person valueobject contains a Collection called allApplications which is mapped to the Application valueobject. Now, I have implemented a search. You may search on attributes that are either related to the Person (such as SSN) or Application (such as date of submission of application). Since a person can contain 0 or more applications, I am searching using a getCollectionByQuery(Person.class, ...) meaning that when I search, my results are a collection of Person objects that match both the person and application related search criteria. [NOTE: I am using allApplication.dateOfSubmission type of attributes when I want to create search criteria that relate to the application table and not the person table.] Now, in the search results, I am supposed to display attributes that come from both the Person and the Application tables, so when getting the Application I have to use Person.getAllApplications(). When I do this, I get the ALL the applications belonging to the person. What I want to do is LIMIT the contents of the allApplications Collection to just the applications that satisfy the search criteria. Could you suggest a way out here? Our current implementation is: First query and get the collection of Person valueobjects. Then, query on the Application table and get all applications belonging to this person which satisfy the search criteria pertaining to the application table. Then, set these applications (which have been obtained by a getCollectionByQuery()) to the person's allApplication collection object: aPerson.setAllApplications(getCollectionByQuery()); This means a database call for every person, to retrieve his applications, which suggests that we seem to have something wrong as far as the use of OJB is concerned. Thanks and Regards Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More elements : Problem using getCollectionByQuery
Hi Andre, I guess the problem is: the collection returned by getCollectionByQuery() contains dynamic proxies, not MGT_Requests. So you should cast to an interface that MGT_Request should implement if you want to use dynamic proxies (does it?), see http://db.apache.org/ojb/tutorial3.html#Using%20Dynamic%20Proxies You may force materialization, just call get method for some persistent field before results.add(resMGT_Request); BTW your current workaround should be quite efficient due to proxy prefetching (new OJB feature). Regards, Oleg On Tuesday 27 January 2004 13:04, A Leg wrote: Oleg Thank you for your answer. emptyArray is just empty. And it is correct if you refer to Collection.toArray apiDoc. I made tries with and without emtyArray param, taking in count that both solutions exists. And I get the same result. Plus it works good when I fill the Collection by this code : (I use getCollectionByQuery only to get the iterator). Iterator iter = collectionResult.iterator(); Collection results = new Vector(); while (iter.hasNext()) { exMGT_Request.setJobNum(new BigDecimal(id)); resMGT_Request = broker.getObjectByQuery(new QueryByIdentity(exMGT_Request)); iter.next(); results.add(resMGT_Request); id++; } MGT_Request[] resArray = (MGT_Request[])results.toArray(emptyArray); I use this code as turnaround. But as you can see it is not realy very efficient. If I try to use data of iter.next() casting them to MGT_Request, it just fail also. For this reason my conclusion is that the elements of the Collection returned by getCollectionByQuery are only not valids. I use postgres as dataBase and everything is working good with it beside that. I would appreciate any help, because the turnaround is so bad that I would prefer to drop it. Best regards Andre Legendre Oleg Nitz wrote: Hi Andre, This is more like incorrect usage of Collection.toArray() method than OJB related problem. Please print emptyArray and emptyArray.length before the line MGT_Request[] resArray = (MGT_Request[])acc.toArray(emptyArray); Is emptyArray not null? Is emptyArray.length really 0? Regards, Oleg On Sunday 25 January 2004 13:22, A Leg wrote: Hi I get some more elements on my getCollectionByQuery problem. It seems that elements of the Collection I get are not valid to be casted by my class. If I change to put an Iterator on the Collection it works good as soon I don't try to cast to my Objects. Does anybody can help me ? I am realy stuck. Andre I change the code to : System.out.println(Send COLLECTIONQUERY MGT ); Collection results = (Collection)broker.getCollectionByQuery(listQuery); //System.out.println(Get COLLECTIONQUERY MGT Rows : + results.size()); System.out.println(Get COLLECTIONQUERY MGT Rows : INCONNU); Iterator iter = results.iterator(); Collection acc = new Vector(); System.out.println(Get COLLECTIONQUERY ojbIterator get ); MGT_Request tmpReq = new MGT_Request(); System.out.println(Get COLLECTIONQUERY ojbIterator iter); while (iter.hasNext()) { acc.add(iter.next()); } System.out.println(Get COLLECTIONQUERY ojbIterator done ); MGT_Request[] resArray = (MGT_Request[])acc.toArray(emptyArray); System.out.println(Get COLLECTIONQUERY toArray done ); And I got the error message : Send COLLECTIONQUERY MGT Get COLLECTIONQUERY MGT Rows : INCONNU Get COLLECTIONQUERY ojbIterator get Get COLLECTIONQUERY ojbIterator iter Get COLLECTIONQUERY ojbIterator done java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.Vector.toArray(Vector.java:688) at org.compiere.mfg_scm.dbManager.TaskConsumer.mfgGetCollectionByQuery(Unkno wn Source) at org.compiere.mfg_scm.dbManager.DbManagerImpl.mfgGetCollectionByQuery(Unkn ow n Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java :3 9) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI mp l.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.jav a: 701) at java.lang.Thread.run(Thread.java:534) A Leg wrote: Hi I have some problem using getCollectionByQuery. Here is
RE: WebSphere Site Developer Test Env with P6Spy
Hi Jay, for IDE debugging with WSAD I'm not using a Datasource but a JDBC connection because in the case of the datasource you have to set up the datasource for each developer box manually Cheers, Siegfried Goeschl -Original Message- From: Jay Xu [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:14 AM To: OJB Users List Subject: WebSphere Site Developer Test Env with P6Spy Hello, group, Has anyone successfully configured P6Spy in Websphere Test Environment (5.0) with DataSource? I have a DataSource myDS defined and then changed name to myDSReal. Then I configured P6Spy DataSource with name myDS. Then I modified spy.properties as follows, realdriver=com.ibm.as400.access.AS400JDBCDriver realdatasource=myDSReal realdatasourceclass=com.ibm.websphere.rsadapter.DB2AS400DataStoreHelper realdatasourceproperties=port;3306,serverName;myserver I do see a spy.log file is created, but see following error from console, [1/27/04 16:53:20:851 PST] de42baf FreePool E J2CA0046E: Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/ms4pib, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA8101E: DataSource class cannot be used as one-phase: ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.init(DataStoreAdapterException.java:222) at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException. If you have successfully configured P6Spy in WebSphere Test Env 5.0 with DataSource, please help! Thank you! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using VerifyMappingTask
Hi Thomas, thanks for your answer. I checked again, but still I get a NoClassDefFoundError. Unfortuanately there is not stacktrace so it is quite difficult to find it. The class kos.generator.DataObject is located in the ojb-generator.jar file. This jar is correct because I am using this JAR at several targets in my build-file. The -v option of ant does'nt help either. I changed the setting verifyclasspath to verifyClassPath but noting changes. Still the task says that it is adding my JARs to its classloader. Do you have more ideas what I could do? Tino Thomas Dudziak wrote: First, you can always invoke ant with the -v option for more information (or even -debug for usually way too much information). Second, I see in the source of the verify task that the classpath option of the task is called 'verifyClassPath' whereas you have 'verifyclasspath' (note the lowercase). Third, you did not write where the kos.generator.DataObject class is located. If its in the ojb-generator.jar file, then you should check whether the classpath works, for instance by using the java task to invoke this class with the same classpath you're using for the verify task. If you still get a NoClassDefFoundError than you have an error in either the jar or the classpath. If you get an error about that there is no main in the class file, then it might be a bug in the verify task itself. If its not in the ojb-generator.jar file, then you should add the jar containing the class explicitly to the classpath. Hope that helps, Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More elements : Problem using getCollectionByQuery
Oleg Thanks very much for your help. I better understand now. In fact I did'nt want particulary use dynmic proxy. I put it because I look at some examples to create my repository file (I am quite lasy!) Effectively, with my workaround it works good. I will look at the tutorial3 to understand proxy. Another question : I just start to use autoincrement with sequence manager. It works good. Is it any way to get directly the value affected by the sequence manager ? Best regards Andre Oleg Nitz wrote: Hi Andre, I guess the problem is: the collection returned by getCollectionByQuery() contains dynamic proxies, not MGT_Requests. So you should cast to an interface that MGT_Request should implement if you want to use dynamic proxies (does it?), see http://db.apache.org/ojb/tutorial3.html#Using%20Dynamic%20Proxies You may force materialization, just call get method for some persistent field before results.add(resMGT_Request); BTW your current workaround should be quite efficient due to proxy prefetching (new OJB feature). Regards, Oleg On Tuesday 27 January 2004 13:04, A Leg wrote: Oleg Thank you for your answer. emptyArray is just empty. And it is correct if you refer to Collection.toArray apiDoc. I made tries with and without emtyArray param, taking in count that both solutions exists. And I get the same result. Plus it works good when I fill the Collection by this code : (I use getCollectionByQuery only to get the iterator). Iterator iter = collectionResult.iterator(); Collection results = new Vector(); while (iter.hasNext()) { exMGT_Request.setJobNum(new BigDecimal(id)); resMGT_Request = broker.getObjectByQuery(new QueryByIdentity(exMGT_Request)); iter.next(); results.add(resMGT_Request); id++; } MGT_Request[] resArray = (MGT_Request[])results.toArray(emptyArray); I use this code as turnaround. But as you can see it is not realy very efficient. If I try to use data of iter.next() casting them to MGT_Request, it just fail also. For this reason my conclusion is that the elements of the Collection returned by getCollectionByQuery are only not valids. I use postgres as dataBase and everything is working good with it beside that. I would appreciate any help, because the turnaround is so bad that I would prefer to drop it. Best regards Andre Legendre Oleg Nitz wrote: Hi Andre, This is more like incorrect usage of Collection.toArray() method than OJB related problem. Please print emptyArray and emptyArray.length before the line MGT_Request[] resArray = (MGT_Request[])acc.toArray(emptyArray); Is emptyArray not null? Is emptyArray.length really 0? Regards, Oleg On Sunday 25 January 2004 13:22, A Leg wrote: Hi I get some more elements on my getCollectionByQuery problem. It seems that elements of the Collection I get are not valid to be casted by my class. If I change to put an Iterator on the Collection it works good as soon I don't try to cast to my Objects. Does anybody can help me ? I am realy stuck. Andre I change the code to : System.out.println(Send COLLECTIONQUERY MGT ); Collection results = (Collection)broker.getCollectionByQuery(listQuery); //System.out.println(Get COLLECTIONQUERY MGT Rows : + results.size()); System.out.println(Get COLLECTIONQUERY MGT Rows : INCONNU); Iterator iter = results.iterator(); Collection acc = new Vector(); System.out.println(Get COLLECTIONQUERY ojbIterator get ); MGT_Request tmpReq = new MGT_Request(); System.out.println(Get COLLECTIONQUERY ojbIterator iter); while (iter.hasNext()) { acc.add(iter.next()); } System.out.println(Get COLLECTIONQUERY ojbIterator done ); MGT_Request[] resArray = (MGT_Request[])acc.toArray(emptyArray); System.out.println(Get COLLECTIONQUERY toArray done ); And I got the error message : Send COLLECTIONQUERY MGT Get COLLECTIONQUERY MGT Rows : INCONNU Get COLLECTIONQUERY ojbIterator get Get COLLECTIONQUERY ojbIterator iter Get COLLECTIONQUERY ojbIterator done java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.Vector.toArray(Vector.java:688) at org.compiere.mfg_scm.dbManager.TaskConsumer.mfgGetCollectionByQuery(Unkno wn Source) at org.compiere.mfg_scm.dbManager.DbManagerImpl.mfgGetCollectionByQuery(Unkn ow n Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java :3 9) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI mp l.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at
Re: I found a problem(it is maybe a bug)
hi dogie, i can't see the difference between the two mappings except the sequence of the definition of the IA-classes :( do you have an sql trace to show the different behaviour ? jakob wrote: Hi! Armin I found if a class implement 2 interface, another class referance a interface of both. OJB can not prefetch the referance object successfully. Example: public class A implement IA1,IA2{ private String OID; public String getOID(){ return OID; } public void setOID(String pNewValue){ OID = pNewValue; } : : } public interface IA1{ } public interface IA2{ } public class B{ private String AOID; public String getAOID(){ return AOID; } public void setAOID(String pNewValue){ AOID= pNewValue; } private A referanceA; public A getReferanceA(){ return referanceA; } public void setReferanceA(A pNewValue){ referanceA= pNewValue; } } if i declare repository_user: class-descriptor class=IA1 extent-class class-ref=A/ /class-descriptor class-descriptor class=IA2 extent-class class-ref=A/ /class-descriptor class-descriptor isolation-level=optimistic class=A table=A field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ : : /class-descriptor class-descriptor isolation-level=optimistic class=B table=B field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ field-descriptor name=AOID column=AOID jdbc-type=CHAR nullable=false/ reference-descriptor name=referanceA class-ref=IA1 foreignkey field-ref=AOID/ /reference-descriptor /class-descriptor I query a B class, but when I call getReferanceA method , it return null. I found something wrong in associateBatched method of org.apache.ojb.broker.accesslayer.ReferencePrefetcher. In line 115 of org.apache.ojb.broker.accesslayer.ReferencePrefetcher, the id is IA1(OID),but in line 119 the id2 is IA2(OID). So in line 120 ,the two parameters is not qeual, and don't excute set. But if I repository_user: class-descriptor class=IA2 extent-class class-ref=A/ /class-descriptor class-descriptor class=IA1 extent-class class-ref=A/ /class-descriptor class-descriptor isolation-level=optimistic class=A table=A field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ : : /class-descriptor class-descriptor isolation-level=optimistic class=B table=B field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ field-descriptor name=AOID column=AOID jdbc-type=CHAR nullable=false/ reference-descriptor name=referanceA class-ref=IA1 foreignkey field-ref=AOID/ /reference-descriptor /class-descriptor I can query B and get A by calling getReferanceA method. Because the id and id2 both are IA1(OID). Dose anyone have the same problem? regards, Dogie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using VerifyMappingTask
On Wed, 28 Jan 2004, [ISO-8859-1] Tino Schöllhorn wrote: Hi Thomas, thanks for your answer. I checked again, but still I get a NoClassDefFoundError. Unfortuanately there is not stacktrace so it is quite difficult to find it. The class kos.generator.DataObject is located in the ojb-generator.jar file. This jar is correct because I am using this JAR at several targets in my build-file. The -v option of ant does'nt help either. I changed the setting verifyclasspath to verifyClassPath but noting changes. Still the task says that it is adding my JARs to its classloader. Do you have more ideas what I could do? The verify task explicitly uses a classloader so there might be a problem there. You could debug the verify task but that involves debugging OJB. You would run your ant target in debug mode an IDE (by calling the ant main class directly - see the ant.bat/.sh file for what the name of that class is and what libraries it requires). There you then can place a breakpoint in the task class (org.apache.ojb.broker.ant.VerifyMappingsTask) in method getPersistentFieldClass to see what the classloader gets and does. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More elements : Problem using getCollectionByQuery
On Wednesday 28 January 2004 17:01, A Leg wrote: Thanks very much for your help. I better understand now. In fact I did'nt want particulary use dynmic proxy. I put it because I look at some examples to create my repository file (I am quite lasy!) Effectively, with my workaround it works good. I will look at the tutorial3 to understand proxy. Maybe you just don't need proxies here? ;-) Another question : I just start to use autoincrement with sequence manager. It works good. Is it any way to get directly the value affected by the sequence manager ? Sorry, I don't know the answer. Anyone else? Regards, Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More elements : Problem using getCollectionByQuery
Another question : I just start to use autoincrement with sequence manager. It works good. Is it any way to get directly the value affected by the sequence manager ? Not sure what exactly are you asking for. Can you please rephrase your question? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Closing ODMG JDBC Connection
Hi All, We're using a hsqldb database for part of our application, and need to package the database files up into a zip archive before exiting. Problem is, OJB doesn't seem to be closing the database connection so the files are still locked and we can't delete them once they are in the Zip file. We use a single db reference throughout out application, initialised by db = OJB.getInstance().newDatabase(null); When we go to shut it down, we call db.close(); Are we missing some obvious step, or do we need to start playing with finalize()? I have tested that hsqldb releases the file locks when the jdbc connection is closed via a call to connection.close(). Thanks for your help, Rob :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Closing ODMG JDBC Connection
Not closing the connection is kind of the whole point of connection pooling, and OJB provides connection pooling. Database connections are typically expensive to establish, so rather than each time you use the database creating a new connection and then releasing it at the end connections are maintained in a pool and just borrowed for a period of time and then returned so other clients can use them. It looks like you can specify different connection pooling implementations though so what you want is probably to set the following in OJB.properties: ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl -Original Message- From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 5:08 PM To: [EMAIL PROTECTED] Subject: Closing ODMG JDBC Connection Hi All, We're using a hsqldb database for part of our application, and need to package the database files up into a zip archive before exiting. Problem is, OJB doesn't seem to be closing the database connection so the files are still locked and we can't delete them once they are in the Zip file. We use a single db reference throughout out application, initialised by db = OJB.getInstance().newDatabase(null); When we go to shut it down, we call db.close(); Are we missing some obvious step, or do we need to start playing with finalize()? I have tested that hsqldb releases the file locks when the jdbc connection is closed via a call to connection.close(). Thanks for your help, Rob :) - 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: Using VerifyMappingTask
I've changed the verify ant task so that it now accepts a classpath sub-tag instead of the verifyClassPath attribute. Check the build.xml in CVS to see how its used. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
properly way to lookup a java.sql.Connection from the connection pool
dear ojb user group, could you kindly tell me the properly way to look a connection from the connection pool? i have used the following call, but i get a socked closed exception. Connection conn = pBroker.serviceConnectionManager().getConnection(); 2004-01-27 10:45:46,609 [RMI TCP Connection(126)-162.86.116.94] ERROR [com.server.TBean] java.sql.SQLException: Io exception: Socket closed your assistance is much appreciated, chris - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!
RE: Closing ODMG JDBC Connection
Hi Lance, Pools are great and I don't really want to get rid of that by using ConnectionFactoryNotPooledImpl. However, I found part of the answer. Each of the ConnectionFactory's has a releaseAllResources method which will close all the connections in the pool (exactly what I want). Anyway, after much mailing list searching and code reading this seems to work... PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(((DatabaseImpl)OJB.getI nstance().getDatabase(null)).getPBKey()); ((ConnectionManagerImpl)broker.serviceConnectionManager()).getUnderlying ConnectionFactory().releaseAllResources(); OJB.getInstance().getDatabase(null).close(); Relatively nasty... Maybe it should go in the faq or there should be an easier way of getting to it (there probably is - how?) Thanks for your help, Rob :) -Original Message- From: Lance Eason [mailto:[EMAIL PROTECTED] Sent: Thursday, 29 January 2004 12:19 p.m. To: OJB Users List Subject: RE: Closing ODMG JDBC Connection Not closing the connection is kind of the whole point of connection pooling, and OJB provides connection pooling. Database connections are typically expensive to establish, so rather than each time you use the database creating a new connection and then releasing it at the end connections are maintained in a pool and just borrowed for a period of time and then returned so other clients can use them. It looks like you can specify different connection pooling implementations though so what you want is probably to set the following in OJB.properties: ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.Conne ctionFactoryNotPooledImpl -Original Message- From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 5:08 PM To: [EMAIL PROTECTED] Subject: Closing ODMG JDBC Connection Hi All, We're using a hsqldb database for part of our application, and need to package the database files up into a zip archive before exiting. Problem is, OJB doesn't seem to be closing the database connection so the files are still locked and we can't delete them once they are in the Zip file. We use a single db reference throughout out application, initialised by db = OJB.getInstance().newDatabase(null); When we go to shut it down, we call db.close(); Are we missing some obvious step, or do we need to start playing with finalize()? I have tested that hsqldb releases the file locks when the jdbc connection is closed via a call to connection.close(). Thanks for your help, Rob :) - 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: Do I need to create reference objects when storing object?
Hi, In the previous versions of OJB it wasnt necessary to create reference object when storing object that has reference but when I try the same thing with OJB 1.0 RC5 the FK fields are set by OJB to null. Is creating the reference object the right thing to do or is there some way to disable this ojb functionality? Why this is not the case with OJB 0.9.7! Because I used OJB 0.9.7 for half of year and there were no problems! ok, I changed this behaviour in CVS head. Now it is possible to store a *new* pc object with populated FK, but without materialized reference. The FK fields are not set to null. Note: This only works for insert operations (storing of new objects), for update the FK fields will be set to null, when reference object is null. regards, Armin Armin Waibel wrote: Hi again, I will write some tests for the problem and try to fix it (if possible ;-)) before new release. regards, Armin Jurica Viskovic wrote: Hy Armin Thank you for replaying so quickly. About the 'access' attribute in reference-descriptor of Bmg21. That's my stupidity because I read in some blog that it could help and I forgotten to move it later on. Object Bmt05 object exists. So there is no problem there. Going through the source code of the PersistenceBrokerImpl I found out that assertFkAssignment and storeReferences methods are setting my fields to null but I don't know why?? Why this is not the case with OJB 0.9.7! Because I used OJB 0.9.7 for half of year and there were no problems! If this is the bug is there some way to fix it before the new release! Thanks, Jure - 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: I found a problem(it is maybe a bug)
OK!! Uppers of the two mappings, IA1 is declared first. The other one ,IA2 is declared first. - Original Message - From: Jakob Braeuchi [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Thursday, January 29, 2004 2:17 AM Subject: Re: I found a problem(it is maybe a bug) hi dogie, i can't see the difference between the two mappings except the sequence of the definition of the IA-classes :( do you have an sql trace to show the different behaviour ? jakob wrote: Hi! Armin I found if a class implement 2 interface, another class referance a interface of both. OJB can not prefetch the referance object successfully. Example: public class A implement IA1,IA2{ private String OID; public String getOID(){ return OID; } public void setOID(String pNewValue){ OID = pNewValue; } : : } public interface IA1{ } public interface IA2{ } public class B{ private String AOID; public String getAOID(){ return AOID; } public void setAOID(String pNewValue){ AOID= pNewValue; } private A referanceA; public A getReferanceA(){ return referanceA; } public void setReferanceA(A pNewValue){ referanceA= pNewValue; } } if i declare repository_user: class-descriptor class=IA1 extent-class class-ref=A/ /class-descriptor class-descriptor class=IA2 extent-class class-ref=A/ /class-descriptor class-descriptor isolation-level=optimistic class=A table=A field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ : : /class-descriptor class-descriptor isolation-level=optimistic class=B table=B field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ field-descriptor name=AOID column=AOID jdbc-type=CHAR nullable=false/ reference-descriptor name=referanceA class-ref=IA1 foreignkey field-ref=AOID/ /reference-descriptor /class-descriptor I query a B class, but when I call getReferanceA method , it return null. I found something wrong in associateBatched method of org.apache.ojb.broker.accesslayer.ReferencePrefetcher. In line 115 of org.apache.ojb.broker.accesslayer.ReferencePrefetcher, the id is IA1(OID),but in line 119 the id2 is IA2(OID). So in line 120 ,the two parameters is not qeual, and don't excute set. But if I repository_user: class-descriptor class=IA2 extent-class class-ref=A/ /class-descriptor class-descriptor class=IA1 extent-class class-ref=A/ /class-descriptor class-descriptor isolation-level=optimistic class=A table=A field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ : : /class-descriptor class-descriptor isolation-level=optimistic class=B table=B field-descriptor name=OID column=OID jdbc-type=CHAR primarykey=true autoincrement=true nullable=false/ field-descriptor name=AOID column=AOID jdbc-type=CHAR nullable=false/ reference-descriptor name=referanceA class-ref=IA1 foreignkey field-ref=AOID/ /reference-descriptor /class-descriptor I can query B and get A by calling getReferanceA method. Because the id and id2 both are IA1(OID). Dose anyone have the same problem? regards, Dogie - 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]
Can anyone help me with this Join question?
I am using OJB to do a simple 1:1 mapping and would like to create a Join between these two tables. The OJB works and I got all database fields I want. But instead of creating a Join, OJB creates TWO SQL statement. From P6Spy, 1075339115137|571|0|statement|SELECT A0.MSVBY,A0.MSDBY,A0.MSTIME,A0.MSDTIME,A0.MSCHTM,A0.MSPACCT#,A0.MSTO,A0.MSVT IME,A0.MSTEXT,A0.MSRSTS,A0.MSFROM,A0.MSFLAG,A0.MSSTS,A0.MSPREL,A0.MSCHDT,A0. MSDATE,A0.MSID,A0.MSDDATE,A0.MSCHBY,A0.MSVDATE,A0.MSPUREF,A0.MSTYPE FROM JMPIBMS2 A0|SELECT A0.MSVBY,A0.MSDBY,A0.MSTIME,A0.MSDTIME,A0.MSCHTM,A0.MSPACCT#,A0.MSTO,A0.MSVT IME,A0.MSTEXT,A0.MSRSTS,A0.MSFROM,A0.MSFLAG,A0.MSSTS,A0.MSPREL,A0.MSCHDT,A0. MSDATE,A0.MSID,A0.MSDDATE,A0.MSCHBY,A0.MSVDATE,A0.MSPUREF,A0.MSTYPE FROM JMPIBMS2 A0 And 1075339117740|460|0|statement|SELECT A0.USEX,A0.UREF#,A0.UBRMM,A0.UBRCY,A0.UBRDD FROM PHPUNIT A0 WHERE A0.UREF# IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )|SELECT A0.USEX,A0.UREF#,A0.UBRMM,A0.UBRCY,A0.UBRDD FROM PHPUNIT A0 WHERE A0.UREF# IN ( '2197' , '2196' , '2 This actually created 1+n SQL statements on the server. I followed the turtorial and did exactly what the turtorial said. But still no Join created by OJB. Could anyone please help me on this? We are in the process to decide if we would use OJB in our project. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Easy question
I read the page on queries: http://db.apache.org/ojb/query.html#report I noticed two kinds of queries. First, a QueryByCriteria: Query q = QueryFactory.newQuery(Person.class, crit); And second, a ReportQueryByCriteria: ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit); What's the difference between the two? After looking at 60+ messages in the mail archive, I'm guessing that it's the fact that the ReportQueryByCriteria allows the creation of summary/aggregate columns such as max(), min(), avg(), ... Am I right? Also, shouldn't the example for ReportQueryByCriteria declare q as: ReportQuery q = QueryFactory.newReportQuery(ProductGroup.class, crit); // Use the ReportQuery interface instead of the ReportQueryByCriteria class Thanks for the help! -Anthony - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]