-->
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.  [ 1 post ] 
Author Message
 Post subject: Unexpected Token!What am I doing wrong?
PostPosted: Wed Apr 13, 2011 12:51 pm 
Newbie

Joined: Wed Apr 13, 2011 12:30 pm
Posts: 2
Hi,
I have two entity classes phone and link. The phone has a one to many relation with link on pin.Since I want a query that returns the count as well as some fields I have another POJO called details grid in the package mars.util which has similar fields as the items the query fetches.
I am also using JPA as a wrapper. Here is the query I have:
Code:
Query q = manager.createQuery("Select new mars.util.DetailsGrid(lp.psn_pin,lp.seq_num,lp.phone," +
               "                              count(distinct src.srcname),min(src.date_reported),max(src.date_reported),count(src.date_reported))" +
                                              "From Phone lp Join lp.phonevaluelink src"+
                                               "Where lp.psn_pin = :pin"+
                                               "Group By lp.phone" +
                                               "Order by max(src.date_reported) desc");
         q.setParameter("pin",pin);
         List<DetailsGrid> griddetails= q.getResultList();

My entities Phone looks something like this:
Code:
public class Phone implements Serializable{
private long psn_pin;
...
private Set<PhoneValueLink> phonevaluelink;
@Id
@Column(name="PSN_PIN")
public long getPsn_pin() {
   return psn_pin;
}
public void setPsn_pin(long psnPin) {
   psn_pin = psnPin;
}
...
....
@OneToMany(mappedBy ="phone")
public Set<PhoneValueLink> getPhonevaluelink() {
   return phonevaluelink;
}
public void setPhonevaluelink(Set<PhoneValueLink> phonevaluelink) {
   this.phonevaluelink = phonevaluelink;
}




And My Phonevaluelink is something like this
Code:
public class PhoneValueLink implements Serializable  {
...
..
private Phone phone;
..
@ManyToOne
@JoinColumn(name="PSN_PIN", referencedColumnName="PSN_PIN", insertable=false, updatable=false)
public Phone getphone() {
   return lphone;
}

public void setphone(Phone phone) {
   this.phone = phone;
}



The error I am getting now is:
unexpected token: lp
12:44:26,269 ERROR [] java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: lp near line 1,


Any idea what I am doing wrong?


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

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.