facebook

how to use the method "findByExample(Object)"?

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #268865 Reply

    xsjohn
    Member

    hello!every one..i ‘m a chinese.my english is not very good.
    here ,i want to kown that how to use the method “findByExample(Object)” in DAO Class..
    thank u 😳

    #268869 Reply

    Steve Prior
    Member

    Here’s a sketch:

    YourClass foo = new YourClass();
    foo.setSomeAttribute(“examplevalue”);
    List myList = dao.findByExample(foo);

    Note that findByExample ONLY works on attributes for the class you’re retrieving, NOT relations and apparently not ID members.
    Any attributes you leave as null will be treated as “don’t cares” in the retrieval. You can retrieve ALL the objects by doing the degenerate case of:

    YourClass foo = new YourClass();
    List myList = dao.findByExample(foo);

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: how to use the method "findByExample(Object)"?

You must be logged in to post in the forum log in