Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed on ejb query  RSS feed

 
Maya Pillai
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please find the code block below.

private List<VendorBean> itemVendor=null;
String query = "select v from VendorBean v order by v.createdDate desc ";
public void getNextItems(String query) {
System.out.println("getNextItems");
try{

Query q = em.createQuery(query);

q.setMaxResults(batchSize);
q.setFirstResult(firstItem);
itemVendor= q.getResultList();
index = firstItem;
}catch (Exception e) {
e.printStackTrace();
}
}

The above code works fine


String query = "select v.vendorName,v.vendorId,v.vendorEmail from VendorBean v order by v.createdDate desc ";
public void getNextItems(String query) {
System.out.println("getNextItems");
try{

Query q = em.createQuery(query);

q.setMaxResults(batchSize);
q.setFirstResult(firstItem);
itemVendor= q.getResultList(); // error from this line
index = firstItem;
}catch (Exception e) {
e.printStackTrace();
}
}

This will thows an exception(NumberFormatException)

Can anyone suggest a solution.

Thanks.
[ December 16, 2008: Message edited by: Maya Pillai ]
 
Maya Pillai
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got solution from here

http://weblogs.java.net/blog/mb124283/archive/2007/04/java_persistenc.html

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!