QBC (Query By Criteria) QBE (Query By Example), qbcqbe

Source: Internet
Author: User

QBC (Query By Criteria) QBE (Query By Example), qbcqbe

QBC reference: (QBC query of Hibernate)

// Is empty and is not empty @ Test public void testQBC () {Session session = sf. getCurrentSession (); session. beginTransaction (); // criterion standard/criterion/standard Criteria c = session. createCriteria (Topic. class) // from Topic. add (Restrictions. gt ("id", 2) // greater than = id> 2. add (Restrictions. lt ("id", 8) // less than = id <8. add (Restrictions. like ("title", "t _")). createCriteria ("category "). add (Restrictions. between ("id", 0, 5) // category. id> = 0 and category. id <= 5; // DetachedCriteria for (Object o: c. list () {Topic t = (Topic) o; System. out. println (t. getId () + "-" + t. getTitle ();} session. getTransaction (). commit ();}

QBE reference: (QBE and QBC of hibernate) and (Summary of Hibernate query methods (HQL, QBC, and QBE)

1 // is empty and is not empty 2 // QBC Query By Criteria 3 // QBE Query By Example 4 @ Test 5 public void testQBE () {6 Session session = sf. getCurrentSession (); 7 session. beginTransaction (); 8 9 Topic tExample = new Topic (); 10 tExample. setTitle ("T _"); 11 Example e = Example. create (tExample) 12. ignoreCase (). enableLike (); // construct example13 14 Criteria c = session. createCriteria (Topic. class) 15. add (Restrictions. gt ("id", 3) 16. add (Restrictions. lt ("id", 8) 17. add (e) 18; 19 20 for (Object o: c. list () {21 Topic t = (Topic) o; 22 System. out. println (t. getId () + "-" + t. getTitle (); 23} 24 session. getTransaction (). commit (); 25}

Jar package link: https://pan.baidu.com/s/1kVbVPmZ password: 384f

QBC link: https://pan.baidu.com/s/1dFEHIYt password: nfms

QBE link: https://pan.baidu.com/s/1i4JJa0d password: 2zby

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.