Hql has several minor issues.

Source: Internet
Author: User

 

1. Unable to locate appropriate constructor on class ....

Similar to "select new uservo (U. ID, U. Name) from user u where u. ID> 100"

In this case, uservo must have a constructor that matches the (ID, name) type.

2. Like Fuzzy match:

View plaincopy to clipboardprint?
  1. Public list <user> findusersbyname (string username ){
  2. String hql = "select * from user u where u. name like? "
  3. List <user> result = gethibernatetemplate (). excutequery (hql, "%" + username + "% ");
  4. Return result;
  5. }

Public list <user> findusersbyname (string username) {<br/> string hql = "select * from user u where u. name like? "<Br/> List <user> result = gethibernatetemplate (). excutequery (hql, "%" + username + "%"); <br/> return result; <br/>} 

Note that "%" is passed in as a parameter rather than directly spelled in hql during like fuzzy match.

3. nested query:

Hql supports selct * From where xx in (select * from where ...)

However, hql does not support queries such as select * from (select * from.

1. Unable to locate appropriate constructor on class ....

Similar to "select new uservo (U. ID, U. Name) from user u where u. ID> 100"

In this case, uservo must have a constructor that matches the (ID, name) type.

2. Like Fuzzy match:

View plaincopy to clipboardprint?
  1. Public list <user> findusersbyname (string username ){
  2. String hql = "select * from user u where u. name like? "
  3. List <user> result = gethibernatetemplate (). excutequery (hql, "%" + username + "% ");
  4. Return result;
  5. }

Public list <user> findusersbyname (string username) {<br/> string hql = "select * from user u where u. name like? "<Br/> List <user> result = gethibernatetemplate (). excutequery (hql, "%" + username + "%"); <br/> return result; <br/>} 

Note that "%" is passed in as a parameter rather than directly spelled in hql during like fuzzy match.

3. nested query:

Hql supports selct * From where xx in (select * from where ...)

However, hql does not support queries such as select * from (select * from.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.