RE: How to use DUAL table for multiple types of queries
Andrew, thanks for the quick response. Unfortunately, we're already using a ReportQuery. Here's the code snippet calling OJB: String[] columns = { "ypas.f_GetRotationDate ( " + listingId + "," + locationId + ",'" + zuluStartDate + "') rotationDate" }; Criteria criteria = new Criteria(); Query contactsQuery = QueryFactory.newReportQuery(RotationGenie.class, columns, criteria, false); collection = broker.getCollectionByQuery(contactsQuery); From: "Clute, Andrew" <[EMAIL PROTECTED]> Reply-To: "OJB Users List" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Subject: RE: How to use DUAL table for multiple types of queries Date: Thu, 20 May 2004 14:34:21 -0400 Based on looking in org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement() -- it looks like if no columns are specified, then it will do the multimapped object select, which you are seeing. It is clearer as what to do in the HEAD version, but in RC5, it looks like if you change it over to a ReportQuery, and ask for only that one column that you need, it would work. if (columns == null || columns.length == 0) { /** * MBAIRD: use the appendListofColumnsForSelect, as it finds * the union of select items for all object mapped to the same table. This * will allow us to load objects with unique mapping fields that are mapped * to the same table. */ columnList = appendListOfColumnsForSelect(getSearchClassDescriptor(), stmt); } else { columnList = appendListOfColumns(columns, stmt); } In this case, columns are ones that are specified, which ReportQuery is used for. -Andrew -Original Message- From: Glenn Barnard [mailto:[EMAIL PROTECTED] Sent: Thursday, May 20, 2004 2:10 PM To: [EMAIL PROTECTED] Subject: How to use DUAL table for multiple types of queries I posted this yesterdayWould someone PLEASE help me. Am running out of time. We use Oracle 9 and have several different functions we can call. In OJB, they are all mapped with the table name of DUAL. For example: SELECT function(args) AS column FROM DUAL Our repository.xml has a table entry for each function so that the result is kept in it's own class. For example: and: The problem is that when OJB goes to extract the values from the result set, it tries to do so for 2 columns, fieldName1 and fieldName2. I thought that by specifiying the class name I wanted (e.g., Class1) that OJB would only get the fields for that class. Can anyone advise me how I can do this without resorting to having only one class for a function calls? Oh, I'm using a customized rc5 and cannot upgrade until after this release ships (a timing/resource issue). Thanks ya'll! _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.click-url.com/go/onm00200362ave/direct/01/ - 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] _ Get 200+ ad-free, high-fidelity stations and LIVE Major League Baseball Gameday Audio! http://radio.msn.click-url.com/go/onm00200491ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use DUAL table for multiple types of queries
The only way that I can see is the one in tutorial 3. You have to add a column to DUAL called "CLASS_NAME" specifying which class that row belongs to. http://db.apache.org/ojb/tutorial3.html#Mapping%20All%20Classes%20on%20the%20Same%20Table Charlie Glenn Barnard said the following on 5/20/2004 2:09 PM: I posted this yesterdayWould someone PLEASE help me. Am running out of time. We use Oracle 9 and have several different functions we can call. In OJB, they are all mapped with the table name of DUAL. For example: SELECT function(args) AS column FROM DUAL Our repository.xml has a table entry for each function so that the result is kept in it's own class. For example: and: The problem is that when OJB goes to extract the values from the result set, it tries to do so for 2 columns, fieldName1 and fieldName2. I thought that by specifiying the class name I wanted (e.g., Class1) that OJB would only get the fields for that class. Can anyone advise me how I can do this without resorting to having only one class for a function calls? Oh, I'm using a customized rc5 and cannot upgrade until after this release ships (a timing/resource issue). Thanks ya'll! _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.click-url.com/go/onm00200362ave/direct/01/ - 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 use DUAL table for multiple types of queries
Based on looking in org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement() -- it looks like if no columns are specified, then it will do the multimapped object select, which you are seeing. It is clearer as what to do in the HEAD version, but in RC5, it looks like if you change it over to a ReportQuery, and ask for only that one column that you need, it would work. if (columns == null || columns.length == 0) { /** * MBAIRD: use the appendListofColumnsForSelect, as it finds * the union of select items for all object mapped to the same table. This * will allow us to load objects with unique mapping fields that are mapped * to the same table. */ columnList = appendListOfColumnsForSelect(getSearchClassDescriptor(), stmt); } else { columnList = appendListOfColumns(columns, stmt); } In this case, columns are ones that are specified, which ReportQuery is used for. -Andrew -Original Message- From: Glenn Barnard [mailto:[EMAIL PROTECTED] Sent: Thursday, May 20, 2004 2:10 PM To: [EMAIL PROTECTED] Subject: How to use DUAL table for multiple types of queries I posted this yesterdayWould someone PLEASE help me. Am running out of time. We use Oracle 9 and have several different functions we can call. In OJB, they are all mapped with the table name of DUAL. For example: SELECT function(args) AS column FROM DUAL Our repository.xml has a table entry for each function so that the result is kept in it's own class. For example: and: The problem is that when OJB goes to extract the values from the result set, it tries to do so for 2 columns, fieldName1 and fieldName2. I thought that by specifiying the class name I wanted (e.g., Class1) that OJB would only get the fields for that class. Can anyone advise me how I can do this without resorting to having only one class for a function calls? Oh, I'm using a customized rc5 and cannot upgrade until after this release ships (a timing/resource issue). Thanks ya'll! _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.click-url.com/go/onm00200362ave/direct/01/ - 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 use DUAL table for multiple types of queries
Hi Glenn, > I thought that by specifiying the class name I wanted (e.g., Class1) > that OJB would only get the fields for that class. Can anyone advise me > how I can do this without resorting to having only one class for a > function calls? In the DUAL table is no information instruct OJB which row belongs to which class, so OJB find always all rows in table. To avoid this DUAL needs an additional column 'ojbConcreteClass' with java class name. See in doc http://db.apache.org/ojb/tutorial3.html#Mapping%20All%20Classes%20on%20the%20Same%20Table regards, Armin Glenn Barnard wrote: We use Oracle 9 and have several different functions we can call. In OJB, they are all mapped with the table name of DUAL. For example: SELECT function(args) AS column FROM DUAL Our repository.xml has a table entry for each function so that the result is kept in it's own class. For example: and: The problem is that when OJB goes to extract the values from the result set, it tries to do so for 2 columns, fieldName1 and fieldName2. I thought that by specifiying the class name I wanted (e.g., Class1) that OJB would only get the fields for that class. Can anyone advise me how I can do this without resorting to having only one class for a function calls? Oh, I'm using a customized rc5 and cannot upgrade until after this release ships (a timing/resource issue). Thanks ya'll! _ Learn to simplify your finances and your life in Streamline Your Life from MSN Money. http://special.msn.com/money/0405streamline.armx - 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 use DUAL
I realized. The getBroker then getConnection is the way. Thanks for tips from everyone. Edson Richter - Original Message - From: Charles Anthony To: 'OJB Users List' Sent: Wednesday, September 10, 2003 3:35 AM Subject: RE: How to use DUAL Hi Edson, You say you're working "client-server" with OJB. Assuming that you do all the "persisting" on the server side (i.e. OJB only used on the server), you could use a PBListener for BeforeUpdate/Insert events, and set the datetime then (using a java.sql.Date). If you really just want to execute an arbitrary SQL statement (select TIMESTAMP from DUAL) , that doesn't map to a java class, then the simple answer is No, there is no better way to do it. Essentially : get a broker, get the brokers connection, create and execute the statement, close everything. Cheers, Charles. >-Original Message- >From: Edson Carlos Ericksson Richter >[mailto:[EMAIL PROTECTED] >Sent: 09 September 2003 20:33 >To: OJB Users List >Subject: Re: How to use DUAL > > >About secure messages, you are right. Excuses to mail list users. > >About using new Date(), this works fine if my app is j2ee based (like >JSP, web services and so on), but my app is Swing (by now >client-server) >based, and I need to guarantee that workstation (if I use new Date()) >has date/time correctly set... That isn't what I want. > >A malicious user could change date/time on workstation between process. >I must warranty that I will be using the server date/time so I can be >confident about it. > >Any other tips? > >I've implemented a call to a procedure, obtaining a connection from a >PersistenceBroker... But could be a more "expert" way to do it. > >Thanks for any tips, > >Edson Richter > > > >Em Seg, 2003-09-08 às 12:58, Roland Carlsson escreveu: >> Hi Edson! >> >> The simplest way to do this is to set the date in your >value-object. Eg setMyDate(new Date()); and then store the >object. Since most databases I tested support higher >time-resolutions than whole seconds or in your case (guessing >oracle) 1/10 of a second if I remember correctly it should be >good enough. >> >> Regards >> Roland Carlsson >> >> PS: Please don't send secure messages to a mailinglist. If >you need them to be secure add a hash in the end of the >message so it can be verified to be not alterd. >> >> - Original Message - >> From: Edson Carlos Ericksson Richter >> To: 'OJB Users List' >> Sent: Monday, September 08, 2003 3:56 PM >> Subject: How to use DUAL >> >> >> Hi! >> I want to execute a query in OJB to obtain database server >DATE. The query is >> >> select TIMESTAMP from DUAL >> >> How can I accomplish this using OJB? Should I use Procedures? >> >> >> >> Thanks, >> >> Edson Richter >> >> >> >> --- >> Outgoing mail is certified Virus Free. >> Checked by AVG anti-virus system (http://www.grisoft.com). >> Version: 6.0.515 / Virus Database: 313 - Release Date: 1/9/2003 > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.516 / Virus Database: 313 - Release Date: 1/9/2003
RE: How to use DUAL
Hi Edson, You say you're working "client-server" with OJB. Assuming that you do all the "persisting" on the server side (i.e. OJB only used on the server), you could use a PBListener for BeforeUpdate/Insert events, and set the datetime then (using a java.sql.Date). If you really just want to execute an arbitrary SQL statement (select TIMESTAMP from DUAL) , that doesn't map to a java class, then the simple answer is No, there is no better way to do it. Essentially : get a broker, get the brokers connection, create and execute the statement, close everything. Cheers, Charles. >-Original Message- >From: Edson Carlos Ericksson Richter >[mailto:[EMAIL PROTECTED] >Sent: 09 September 2003 20:33 >To: OJB Users List >Subject: Re: How to use DUAL > > >About secure messages, you are right. Excuses to mail list users. > >About using new Date(), this works fine if my app is j2ee based (like >JSP, web services and so on), but my app is Swing (by now >client-server) >based, and I need to guarantee that workstation (if I use new Date()) >has date/time correctly set... That isn't what I want. > >A malicious user could change date/time on workstation between process. >I must warranty that I will be using the server date/time so I can be >confident about it. > >Any other tips? > >I've implemented a call to a procedure, obtaining a connection from a >PersistenceBroker... But could be a more "expert" way to do it. > >Thanks for any tips, > >Edson Richter > > > >Em Seg, 2003-09-08 às 12:58, Roland Carlsson escreveu: >> Hi Edson! >> >> The simplest way to do this is to set the date in your >value-object. Eg setMyDate(new Date()); and then store the >object. Since most databases I tested support higher >time-resolutions than whole seconds or in your case (guessing >oracle) 1/10 of a second if I remember correctly it should be >good enough. >> >> Regards >> Roland Carlsson >> >> PS: Please don't send secure messages to a mailinglist. If >you need them to be secure add a hash in the end of the >message so it can be verified to be not alterd. >> >> - Original Message - >> From: Edson Carlos Ericksson Richter >> To: 'OJB Users List' >> Sent: Monday, September 08, 2003 3:56 PM >> Subject: How to use DUAL >> >> >> Hi! >> I want to execute a query in OJB to obtain database server >DATE. The query is >> >> select TIMESTAMP from DUAL >> >> How can I accomplish this using OJB? Should I use Procedures? >> >> >> >> Thanks, >> >> Edson Richter >> >> >> >> --- >> Outgoing mail is certified Virus Free. >> Checked by AVG anti-virus system (http://www.grisoft.com). >> Version: 6.0.515 / Virus Database: 313 - Release Date: 1/9/2003 > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use DUAL
Hi Edson! I think you should be able to use QueryBySQL to solve the problem. It doesn't require you to return a key. But I'm not sure that will work... i know I can create an object of an already existing mapped class... but i'm not sure if it works for this purpose. If you have the time to make a few experiments you might get it to work .. Please tell me about your results.. Regards Roland Carlsson > About secure messages, you are right. Excuses to mail list users. > > About using new Date(), this works fine if my app is j2ee based (like > JSP, web services and so on), but my app is Swing (by now client-server) > based, and I need to guarantee that workstation (if I use new Date()) > has date/time correctly set... That isn't what I want. > > A malicious user could change date/time on workstation between process. > I must warranty that I will be using the server date/time so I can be > confident about it. > > Any other tips? > > I've implemented a call to a procedure, obtaining a connection from a > PersistenceBroker... But could be a more "expert" way to do it. > > Thanks for any tips, > > Edson Richter > > > > Em Seg, 2003-09-08 às 12:58, Roland Carlsson escreveu: > > Hi Edson! > > > > The simplest way to do this is to set the date in your value-object. Eg setMyDate(new Date()); and then store the object. Since most databases I tested support higher time-resolutions than whole seconds or in your case (guessing oracle) 1/10 of a second if I remember correctly it should be good enough. > > > > Regards > > Roland Carlsson > > > > PS: Please don't send secure messages to a mailinglist. If you need them to be secure add a hash in the end of the message so it can be verified to be not alterd. > > > > - Original Message - > > From: Edson Carlos Ericksson Richter > > To: 'OJB Users List' > > Sent: Monday, September 08, 2003 3:56 PM > > Subject: How to use DUAL > > > > > > Hi! > > I want to execute a query in OJB to obtain database server DATE. The query is > > > > select TIMESTAMP from DUAL > > > > How can I accomplish this using OJB? Should I use Procedures? > > > > > > > > Thanks, > > > > Edson Richter > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.515 / Virus Database: 313 - Release Date: 1/9/2003 > > > - > 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 use DUAL
About secure messages, you are right. Excuses to mail list users. About using new Date(), this works fine if my app is j2ee based (like JSP, web services and so on), but my app is Swing (by now client-server) based, and I need to guarantee that workstation (if I use new Date()) has date/time correctly set... That isn't what I want. A malicious user could change date/time on workstation between process. I must warranty that I will be using the server date/time so I can be confident about it. Any other tips? I've implemented a call to a procedure, obtaining a connection from a PersistenceBroker... But could be a more "expert" way to do it. Thanks for any tips, Edson Richter Em Seg, 2003-09-08 às 12:58, Roland Carlsson escreveu: > Hi Edson! > > The simplest way to do this is to set the date in your value-object. Eg > setMyDate(new Date()); and then store the object. Since most databases I tested > support higher time-resolutions than whole seconds or in your case (guessing oracle) > 1/10 of a second if I remember correctly it should be good enough. > > Regards > Roland Carlsson > > PS: Please don't send secure messages to a mailinglist. If you need them to be > secure add a hash in the end of the message so it can be verified to be not alterd. > > - Original Message - > From: Edson Carlos Ericksson Richter > To: 'OJB Users List' > Sent: Monday, September 08, 2003 3:56 PM > Subject: How to use DUAL > > > Hi! > I want to execute a query in OJB to obtain database server DATE. The query is > > select TIMESTAMP from DUAL > > How can I accomplish this using OJB? Should I use Procedures? > > > > Thanks, > > Edson Richter > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.515 / Virus Database: 313 - Release Date: 1/9/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use DUAL
Hi Edson! The simplest way to do this is to set the date in your value-object. Eg setMyDate(new Date()); and then store the object. Since most databases I tested support higher time-resolutions than whole seconds or in your case (guessing oracle) 1/10 of a second if I remember correctly it should be good enough. Regards Roland Carlsson PS: Please don't send secure messages to a mailinglist. If you need them to be secure add a hash in the end of the message so it can be verified to be not alterd. - Original Message - From: Edson Carlos Ericksson Richter To: 'OJB Users List' Sent: Monday, September 08, 2003 3:56 PM Subject: How to use DUAL Hi! I want to execute a query in OJB to obtain database server DATE. The query is select TIMESTAMP from DUAL How can I accomplish this using OJB? Should I use Procedures? Thanks, Edson Richter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.515 / Virus Database: 313 - Release Date: 1/9/2003