Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are?
Join them; it only takes a minute:
|
|
You might want to check out the quaere project. Its a java framework that adds a way to query collections, similar to how LINQ works. |
|||||||||
|
|
Consider using Querydsl : http://www.querydsl.com It supports JPA/Hibernate, JDO, SQL and Collections. Querydsl is fully type-safe, supports autocomplete in IDEs and provides a common querying syntax on top multiple backends. I am the maintainer of Querydsl, and I wrote a comparison to other frameworks some time ago. It is slightly biased, but shows the different emphasis
Newer frameworks experiment also with closure syntax. |
|||||||||
|
|
There is a Java project called JoSQL which provides object querying capabilities with a SQL-like syntax. |
|||||
|
|
Java does not have a Linq equivalent. However Scala, a functional language that compiles to Java byte code, has something closes: an extended for loop syntax. |
|||
|
|
|
Have a look at JaQue. |
|||||
|
|
For database-heavy work, SQLJ might be an option. The downside is it's not pure Java and requires a pre-processor. |
|||
|
|
|
For LINQ (LINQ to Objects to be more accurate) you can use Streams starting from Java 8 This doesn't work for databases however, only for internal objects like Collections and Lists It is really powerfull, but not as complete as LINQ (in my opinion) Check out this tutorial - http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-streams-2177646.html As for Entity Framework there is nothing quite as powerful that I have found yet, but haven't tried all the solutions provided in the other answers |
|||
|
|
|
You won't find an equivalent of LINQ unless you use the javacc to create your own equivalent. Until that day when someone finds a viable way to do so, there are some good alternatives, such as |
|||
|
|
|
There is no exact alternative which is universal as LINQ is. However if we are talking about LINQ to SQL then JPA is really an alternative when you use it with an IDE that supports "Inject language" feature. E.g. IDEA will do full scale completion of the JPA query within a string |
|||
|
|