views:

144

answers:

1

I have project use EJB 3.0 and implement Toplink framework for model layer.

When using EJBQL to process data, I see it seems have some limitation:

  • It cannot process datatime such as find a part of date such as day, month or year
  • It cannot find datetime among from...to
  • It cannot comparison datetime field
  • It cannot map a class not entity to a customize native select query because I want to get List data from SELECT statement but when I query in case join 2 or more table and map the object output into a class but impossible

@PersistenceContext private EntityManager em;

em.createNativeQuery("SELECT a.usertype , b.username, b.userpass FROM tablea a, tableb b WHERE a.id = b.id,MyClass.class).getResultList

.....

class MyClass(){
String usertype;
String username;
String userpass;

}

Could you help me any ideas?

Thank in advance!

A: 
  • It can not, do it in your code. Otherwise, you need to use something database specific on one side of your condition.
  • It can, why not. You can use between :fromDate and :toDate in the query, or use > :fromDate and < :toDate, in the NamedQuery. Where is the problem.
  • It can. Similar to the last one, use = sign instead
  • It can using @SqlResultSetMapping. Refer to this.
Adeel Ansari