-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: HQL Problem : Unexpected Token
PostPosted: Wed Sep 07, 2005 10:25 pm 
Newbie

Joined: Wed Sep 07, 2005 10:17 pm
Posts: 2
Hi,

Can anyone help with the following?

I am getting the following error:

org.hibernate.hql.PARSER *** ERROR: line 1:144: unexpected token: date


when I run the HQL:

FROM Customer as c where c.firstName LIKE :firstName and c.surname=:surname and c.dob=:dob and c.memberEndDate>current date

I am using Hibernate 3.0 with Db2.

There is no error when I remove the "and c.memberEndDate>current date"

My mapping is:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
<hibernate-mapping>


<class
    name="au.com.hbf.travel.model.Customer"
    table="WW202_CUSTOMER"
>
   
    <id
        name="id"
        type="java.lang.Integer"
        column="CUSTOMER"
    >
    </id>
   
   
    <property
        name="surname"
        type="java.lang.String"
        column="SURNAME"
        not-null="true"
        length="30"
    />   
   
    <property
        name="firstName"
        type="java.lang.String"
        column="GIVEN"
        not-null="true"
        length="30"
        />
    <property
        name="dob"
        type="java.sql.Date"
        column="BIRTH_DTE"
        not-null="true"
        length="10"
    />
   
    <property
        name="memberEndDate"
        type="java.sql.Date"
        column="MEMBER_END_DTE"
        not-null="true"
        length="10"
    />


</class>
</hibernate-mapping>


and the class is:

Code:
public class Customer extends BaseTravelModel
{
   private String firstName = null;
   private String surname = null;
   private Date dob = null;
   private Date memberEndDate = null;
   
   public Customer()
   {
      super();
   }

   public Customer(String id, String firstName, String surname, Date dob)
   {
      super(id);
      this.firstName = firstName;
      this.surname = surname;
      this.dob = dob;
   }

   public Date getDob()
   {
      return dob;
   }

   public String getFirstName()
   {
      return firstName;
   }

   public String getSurname()
   {
      return surname;
   }

   public void setDob(Date date)
   {
      dob = date;
   }

   public void setFirstName(String string)
   {
      firstName = string;
   }

   public void setSurname(String string)
   {
      surname = string;
   }
   
   public Date getMemberEndDate()
   {
      return memberEndDate;
   }

   public void setMemberEndDate(Date date)
   {
      memberEndDate = date;
   }

   protected String paramString()
   {
      super.paramString();
      StringBuffer buffer = new StringBuffer();
      buffer.append( "FirstName = " + getFirstName() );
      buffer.append( "Surname = " + this.getSurname() );
      buffer.append( "DOB = " + this.getDob() );
      buffer.append( "EndDate = " + this.getMemberEndDate() );
      
      return  buffer.toString();
   }
   

}


Top
 Profile  
 
 Post subject: Re: HQL Problem : Unexpected Token
PostPosted: Wed Sep 07, 2005 10:34 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
yaq wrote:
FROM Customer as c where c.firstName LIKE :firstName and c.surname=:surname and c.dob=:dob and c.memberEndDate>current date


Make 'current date' one token (a string of chars w/ no space ).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 10:54 pm 
Newbie

Joined: Wed Sep 07, 2005 10:17 pm
Posts: 2
yep

I changed it to "current_date" and now it works.

I thought something else must be wrong, because I had copied similar HQL from places like :

http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html

where "current date" is refered to.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 11:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I will fix that bug in the docs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.