EJBQL, MIN and java.sql.Timestamp

I am trying to create a new finder method for a cmp bean which returns me the date of the oldest bean available.
the ejbql query looks like this:
select MIN (a.receiveDate) from AssetSchema as a
receiveDate is defined as a java.sql.Timestamp field in the bean. I am getting the following error:
Bean: Asset
Method: clover.AssetLocal findOldestDeleted()
EJBQL: select MIN (a.receiveDate) from AssetSchema as a
Error: JDO75334: Invalid type 'java.sql.Timestamp' of select clause expression for finder method.
anything wrong with the query or .....

Instead of using a finder, use an ejbSelect method. You can then use the aggregate function MIN. Wrap the ejbSelect in a home method.
In remote Home interface, define home method:
public java.lang.String selectMinSingle() throws RemoteException;
define the ejbSelect method in EJB class:
public abstract java.lang.String ejbSelectMinSingle() throws FinderException;
The ejbSelect is wrapped in a ejbHome method:
public java.lang.String ejbHomeSelectMinSingle()
try {
String s = ejbSelectMinSingle();
return s;
} catch(Exception e) {
throw new EJBException("ejbHomeSelectMinSingle: " + e);
Call home method from client:
String s1 = beanHome.selectMinSingle();
Not sure if this is what you're looking to do.
There is also the ORDER BY clause; i.e.,
<ejb-ql>Select p.quantity from ProductBean p ORDER BY p.quantity</ejb-ql>
use the ASC or DESC keyword:
<ejb-ql>Select p.quantity from ProductBean p ORDER BY p.quantity ASC</ejb-ql>
For finder:
query>
<description></description>
<query-method>
<method-name>findProductsByHighestQuantity</method-name>
<method-params />
</query-method>
<ejb-ql>Select DISTINCT OBJECT(p) From ProductBean p ORDER BY p.quantity DESC</ejb-ql>

Similar Messages

  • A silly question about oracle.sql.timestamp and java.sql.timestamp

    Hi,
    I'm looking at a method that takes objects of type Object and does stuff if the object is really a java.sql.timestamp. If it is not then an error is flagged. In my case it flags an error when an object of type oracle.sql.timestamp is passed to it. Not really entirely comfortable with java (i'm still learning it), here's my stupid question :- why isn't oracle.sql.timestamp a subclass of java.sql.timestamp? Also in various books it indicates that java.sql.timestamp maps to oracle.sql.timestamp. Does that mean you have to physically do the mapping:
    i.e.
    java.sql.Timestamp t = new Timestamp( new oracle.sql.Timestamp( CURRENTTIMESTAMP ).timestampValue() );
    or is there something else to it.
    Thanks.
    Harold.

    The best forum for this is probably Forum Home » Java » SQLJ/JDBC
    Presumably you are refering to oracle.sql.TIMESTAMP. While this is intended to (and does) correspond to java.sql.Timestamp it can't be a subclass because it needs to be a subclass of oracle.sql.Datum.

  • RQL Error - JQuery Datepicker and java.sql.Timestamp

    Hello everyone,
    I am using JQuery Datepicker to select start and end date range.
    Both start date and end date are successfully passed as like this. 10/01/2013 and 10/31/2013
    It has java.sql.Timestamp mapping in both startDate and endDate.
    Property name in component browser is transactionTimestamp.
    It gives me following error when i passed both parameters.
    <dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
        <dsp:param name="repository" value="/atg/commerce/order/OrderRepository" />
        <dsp:param name="itemDescriptor" value="inStorePaymentStatus" />
        <dsp:param name="queryRQL" value="transactionTimestamp>=:startDate AND transactionTimestamp<:endDate" />
    **** Error    Wed Oct 02 16:07:21 IST 2013    1380710241490    /atg/dynamo/droplet/RQLQueryForEach    unable to parse/execute query due to RepositoryException    CONTAINER:atg.repository.RepositoryException; SOURCE:java.sql.SQLException: java.sql.SQLDataException: ORA-01843: not a valid month
    It gives NO error when i passed single parameter.
      <dsp:param name="queryRQL" value="transactionTimestamp>=:startDate"/>
    can anyone suggest me a solution.
    Thanks
    saminda konkaduwa

    Hi all,
    Found the solution. We have to use parameter converter tools as well. that is the additional parameter called "date" where we passed date format.
    <dsp:param name="startDate" param="10/12/2012" date="MM/dd/yyyy"/>
    <dsp:param name="endDate" param="10/12/2015" date="MM/dd/yyyy"/>
    Explanation :
    JSP FILE ( testing.jsp)
    =================
    <dsp:page>
    <head>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript" src="merchant_portal_ajax_agent_report.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#startDate").datepicker();
        $(function() {
            $("#endDate").datepicker();
    </script>
    </head>
    <body>
    <table>
                        <tr>
                            <td>Start Date</td>
                            <td><input type="text" id="startDate" class="picker" name="sDate" /></td>
                            <td>End Date</td>
                            <td><input type="text" id="endDate" class="picker" name="sDate" /></td>
                            <td><input value="Find" type="submit" class="atg_button" onclick="loadAgentReport()" /></td>                       
                        </tr>
                        <tr>
                                    <div id="agentReportTable"></div>
                        </tr>
    </table>
    </body>
    </dsp:page>
    JAVA SCRIPT FILE (merchant_portal_ajax_agent_report.js)
    ============================================
    function loadAgentReport() {
        var startDateValue = $("#startDate").val();
        var endDateValue = $("#endDate").val();
            $(document).ready(function() {
              $.ajax({
                    type : "POST",
                    url : "merchant_portal_view_agent_report.jsp",
                    data : {
                       startDate : "" + startDateValue + "" , endDate : "" + endDateValue + ""
                    success : function(result) {
                        $("#agentReportTable").html("");
                        $("#agentReportTable").html(result);
    JSP File ( This invoked by Jquery ) merchant_portal_view_agent_report.jsp
    =======================================================
    <dsp:page>
                                <dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
                                    <dsp:param name="repository" value="/atg/commerce/order/OrderRepository" />
                                    <dsp:param name="itemDescriptor" value="inStorePaymentStatus" />
                                    <dsp:param name="queryRQL" value="agentId=:agentId AND transactionTimestamp>:startDate AND transactionTimestamp<:endDate" />
                                    <dsp:oparam name="output">
                                       <dsp:valueof param="element.transactionId"/>  <dsp:valueof param="element.transactionStatus"/>
        </br> 
                                    </dsp:oparam>
                                    <dsp:oparam name="empty">
                                             No data found
                                   </dsp:oparam>
                               </dsp:droplet>
    </dsp:page>
    Thanks
    saminda konkaduwa

  • Ejb-ql and java.sql.Timestamp object

    Hi, I have a mySql database table that has a column containing a Timestamp object. I need a finder method for my ejb's that will allow me to query the table for rows between certain dates.
    In other words, I need to query for entries that have a Timestamp object between 2 specified dates.
    One solution is to change the column type from Timestamp to long (date in milliseconds). That way I can use the BETWEEN clause to search between 2 longs. I would rather not do that. Does anyone know of a way that I can search between 2 Timestamp objects?

    You can use the SQL BETWEEN clause with dates, just use it like this:
    WHERE OrderDate BETWEEN '1998/5/1' AND '1998/5/31'

  • Oracle 9.x and java.sql.Timestamp

    Are there any documents or examples illustrating the interaction of the Oracle 9.x [SQL92] TIMESTAMP and the timezone varient of TIMESTAMP?

    Erm,
    One way to find out, I reckon.
    Good Luck,
    Avi.

  • Usage of java.sql.Timestamp with classes12.zip and ojdbc14.jar  ?

    Hi all,
    If i'm using java.sql.Timestamp with classes12 it is functioning perfectly,
    if i'm using ojdbc14 and java.sql.Timestamp it is functioning in different way and failing to do the action..
    Example : update set xxx=yy where time = my Timestamp object set in Prepared statement
    Hope to see the answer

    http://forum.java.sun.com/thread.jspa?threadID=460615&messageID=2116517
    Timestamp insert problem
    Using the "classes12.zip" file that comes with the distribution for Oracle versions 8.1.6.x and 8.1.7.x, Oracle's DATE datatype is mapped to the "java.sql.Timestamp" class. However, the "ojdbc14.jar" driver maps DATE to "java.sql.Date", and "java.sql.Date" only holds a date (without a time), whereas "java.sql.Timestamp" holds both a date and a time.

  • Conversions between java.util.Date, java.util.Timestamp and java.sql dates

    I am coding a hoilday booking system using JSP to interact with a SQL Server database. On my JSP form which retrieves the information I have a little javascript pop-up date selector which appears to be returning a Timestamp value although the string value is visable in the entry field. Can I pass this to a javabean as a Timestamp, so far I have only passed strings? Also I then have to enter it in the database and so will need to convert it to an sql date type but I dont know which one is best. Previous to using the Timestamp returning calendar I was just entering text and parsing it to a util.Date in the bean and then converting that to an sql.Date for entry in the database. That worked fine but I want to use the pop-up any ideas? Also my bean won't compile if I declare java.util.Timestamp t;(cannot resolve symbol Timestamp !) even though I have imported util.

    First of all, java.util.Timestamp does not exist. You probably need java.sql.Timestamp.
    java.sql.Date and java.sql.Timestamp inherit from java.util.Date. So converting from java.sql.Date or java.sql.Timestamp to java.util.Date is easy, you don't have to do anything.
    To convert a java.util.Date to a java.sql.Timestamp, do something like this:
    import java.sql.Timestamp;
    import java.util.Date;
    Date date = new Date();
    Timestamp ts = new Timestamp(date.getTime());Jesper

  • Can I use ' ', ' ', '= ' and ' =' with java.sql.Timestamp objects in EJB-QL

    ie. Is this valid?
    <query>
    <description>Find data between dates</description>
    <query-method>
    <method-name>findMetricsByDate</method-name>
    <method-params>
    <method-param>java.sql.Timestamp</method-param>
    </method-params>
    <method-params>
    <method-param>java.sql.Timestamp</method-param>
    </method-params>
    </query-method>
    <result-type-mapping>Local</result-type-mapping>
    <ejb-ql>
    SELECT OBJECT (o) FROM MetricResults AS o WHERE MetricResults.date > ?1 AND MetricResults.date < ?2
    </ejb-ql>
    </query>

    No. Not with current EJB 2.0 CMP specs at least. Later revisions are supposed to fix this, but for now, this seriously limits the usefulness of EJB-QL.
    .P.

  • Java.sql.Timestamp creation with value -4712.01.01 (oracle min timestamp)

    How can I create ajava.sql.Timestamp with the value -4712.01.01?
    Trying Timestamp timestamp = new Timestamp( -210863523208000l );leads to the date 4713-02-08 00:06:32.0.
    Or what is the minimal java.sql.timestamp value in Java?
    Edited by: bejq on 17.03.2009 08:56

    bejq wrote:
    Thanks for your quick answer.
    Yes it is 1st January 4712 BC.
    Timestamp timestamp = new Timestamp( -4712, 1, 1, 0, 0, 0, 000 );//deprecated Method
    System.out.println( timestamp ); // returns 2813-02-01 00:00:00.0
    System.out.println( timestamp.getTime() );// returns -150904688400000Thats not what I want.You have lost me then. Unless of course you want to use SimpleDateFormat with an appropriate TZ to parse the date to a java.util.Date and then construct a java.sql.Timestamp from the java.util.Date using the java.util.Date#getTime() method to construct the java.sql.Timestamp .
    Edited by: sabre150 on Mar 17, 2009 10:41 AM

  • Java.sql.Timestamp and the Epoch

    Hello all
    according to the JavaDoc for Timestamp, the long parameter of the constructor represents "milliseconds since January 1, 1970, 00:00:00 GMT". However, running
    class Main
      public static void main (String [] args)
        System.out.println (new java.sql.Timestamp (0l));
    } produces 1970-01-01 01:00:00.0, which is 3.6 million ms since the time stated in the doc.
    My box is set to GMT. Does anyone know of an explanation for this?
    Cheers

    I'd say that extra hour is the daylight savings hour.
    The GMT timezone uses it, but UTC ( Universal time coordinates ) doesn't.
    regards,
    Owen

  • How do I return a java.sql.Timestamp data type in a Web service?

    I'm new to workshop and java. I'm creating a mini application to simulate a real work Web Service (development environment is on an intranet). I was able to completely simulate the Web Services minus all date values.
    I'm using a standard weblogic workshop database controls that are feeding the various WebServices and their methods (Web services was generated from DB control). I get a java type not support error when I attempt to return a java.sql.Timestamp. I temporarily got around the problem by omitting all dates from the sql.
    However, we are at the point where we need the complete record.
    My two questions
    1) What java data type do I convert the java.sql.Timestamp to
    2) Where and how do I do it in workshop.
    Thanks in advance
    Derrick
    Source view from workshop looks something like this.
    public interface MyData extends DatabaseControl, com.bea.control.ControlExtension
    static public class dbOverallRec
    public String key;
    public String field1;
    public int field2;
    public java.sql.Timestamp create_date
    public dbOverallRec () {};
    *@jc:sq; rowset-name="OverallRowSet" statement::
    *select key, field1, field2 ,create_date from overall where key={KEY}::
    dbOverallRec getOverallByKey(String Key);
    * I had to omit the create_date to get it to work

    You should try changing java.sql.Timestamp to java.util.Calendar.
    java.util.Calendar maps to the dateTime type in XML Schema, and TIMESTAMP as a JDBC type.
    Regards,
    Mike Wooten

  • Java.util.Date badly serialized to java.sql.Timestamp Coherence 3.5.2

    Hi all,
    I'm running into this odd behaviour.
    I serialize java.util.Date objects to cache and when I read them back from cache, they appear to be java.sql.Timestamp types.
    I've isolated a junit test for that.
    Do you know why Coherence changes the type in the middle?
    Regards
    Harry.
    import java.util.Date;
    import org.junit.Assert;
    import org.junit.Test;
    import com.tangosol.io.Serializer;
    import com.tangosol.io.pof.ConfigurablePofContext;
    import com.tangosol.util.ExternalizableHelper;
    public class DatePofSerialTest {
         @Test
         public void testCobdate() throws Exception {
              Date date=new Date();
              Serializer serial = new ConfigurablePofContext();//"coherence-pof-config.xml");
              Date date2=(Date)ExternalizableHelper.fromBinary(ExternalizableHelper.toBinary(date, serial), serial);
              System.out.println(serial +" -- Date to serailize ["+ date.getClass() + "]");
              System.out.println(serial +" -- Date from deserialize ["+ date2.getClass() + "]");
              Assert.assertEquals(date, date2);/* Of course this passes, as both refer to the same time (long)*/
    {code}
    This gives as output
    {code:title=output |borderStyle=solid}
    log4j:WARN No appenders could be found for logger (Coherence).
    log4j:WARN Please initialize the log4j system properly.
    com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date to serailize [class java.util.Date]
    com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date from deserialize [class java.sql.Timestamp]
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Harry,
    It looks like the same issue as ...
    PofExtractor with java.util.Date results in ClassCastException
    It was fixed in version 3.5.4.
    Thanks

  • Problem saving java.sql.timestamp

    I am using java.sql.timestamps for all date fields inside the database.
    the client program is using a session bean to insert the data into the database. Afterwards when I do a select in sql plus the date is always 2 hours and 30 minutes above the value I supplied to the database.
    Are there any timezone settings I have to supply on the server ?
    thx in advance
    null

    Please shrink your code down to the bare minimum that compiles and demonstrates the problem. Do not include any tests that pass. Just the one that fails, and describe clearly exactly how it fails--what's expected and what is observed instead.
    You can probably even get rid of the separate test class and just put it all in main, or at least all in the same class with main and one or a small handful of other methods.

  • Java.sql.Timestamp: does not have a no-arg default constructor ERROR

    Hi,
    I am using jaxws(jwsdp2.0) and when i use the apt tool I get this error because I use java.sql.Timestamp as one of the fields in a class. What is the workaround for this problem? Any help is appreciated.
    Thanks,
    Vijay

    I just replaced java.sql.Timestamp to java.util.Date for this to work.
    Any other workaround is welcome.
    Vijay

  • Map java.sql.Timestamp to JDBC-MySQL TIMESTAMP?

    Java provides the java.sql.Timestamp class specifically to be able to make
    use of the greater-accuracy timestamps provided in JDBC and underlying
    datastores. Is there a way to set up a Kodo mapping file such that a
    persistent class with a java.sql.Timestamp field, has this field map to a
    TIMESTAMP field in the underlying database table?
    Thanks,
    -- Bryan

    Yes, with a custom field mapping. See the example of a custom field
    mapping for java.sql.Date in samples/ormapping. A mapping for timestamp
    would be almost exactly the same.

Maybe you are looking for