hql fuzzy Query and de-weight

Source: Internet
Author: User

HQL statements

String hql = "from the Song where name like '%" +text+ "% ' or singer like '%" +text+ "% ' or alumn like '%" +text+ "% '";

Go heavy. Overrides Equals and Hascode of the Pojo class.

@Override
public int hashcode () {
TODO auto-generated Method Stub
return 1;
}

@Override
public boolean equals (Object obj) {
if (obj instanceof Song) {
Song song = (song) obj;
if (This.id.equals (Song.getid ())) {
return true;
}
}
return false;
}

My primary key is ID. I just need the ID in the result to be different. If you need other conditions, you can modify it yourself.

Then the list is transferred to the hashset inside the weight can be.

hql fuzzy Query and de-weight

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.