Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9122999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:14:05+00:00 2026-06-17T06:14:05+00:00

How can I use something like this (Lambda Expression) in Java with JDK7 ?

  • 0

How can I use something like this (Lambda Expression) in Java with JDK7 ?

public virtual IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null)

I am trying to pass this method a where clause to filter the select statement, in C# I can use Lambda expressions and I am searching for a solution to do this in my Java project.

public List<TEntity> Get() {
    List<TEntity> result = emf.createEntityManager().createNamedQuery(ClassName + ".findAll").getResultList();
    return result;
}

This is my Method and i would like to pass a where clause tot this method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:14:06+00:00Added an answer on June 17, 2026 at 6:14 am

    I’m not a C(sharp) person, but isn’t that just the equivalent of:

    Iterable<Entity> get();
    Iterable<Entity> get(Expression<Func<Entity, Boolean>> filter);
    

    Follow up to your edit: I don’t know the .NET library, but a filtering in Java would look something like:

    public interface Predicate<T> {
        boolean matches(T obj);
    }
    ...
    public List<Entity> get(Predicate<Entity> filter) {
        List<Entity> filtered = new ArrayList<>();
        for (Entity obj : ...blah...) {
            if (filter.matches(obj)) {
                filtered.add(obj);
             }
        }
        return filtered;
    }
    

    In the current verbose syntax that would called like:

    List<Entity> entities = thing.get(new Predicate<>() {
        public boolean matches(Entity obj) {
            return obj.isX() && obj.isY();
        }
    });
    

    A more concise syntax with random changes to semantics should be added in Java SE 8, along with library additions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What Swing class can I use to implement something like this? Add To List
Can I use a flag to select different WHERE clause? Something like this. SELECT
I know I can use something like User.sort {|a, b| a.attribute <=> b.attribute} or
In recent versions of python, one can use something like with open('abc.txt') as f:
Just curious, is there a format string I can use to output something like
An ordinary object, I can use o.__repr__() to see something like '<__main__.A object at
What tool or method can I use to see what code something like an
I thought it would be nice to do something like this (with the lambda
I have a LINQ query that looks like this: public IEnumerable<Foo> SelectFooBars() { return
How can I use regex in python to capture something between two strings or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.