Is there any entity framework equivalent in java?

Java.Net

Java Problem Overview


Everyone who programmed with C# knows that there is the Entity Framework as ORM (object-relational mapper) which enable programmer to query database using only C# code.

For example, if I have a database called Shop, and in the Shop database I have Products table, i can get all product of Productstable where their price is less than 2 dollar in the following way:

ShopEntity _Db = new ShopEntity();
List<Product> products = _Db.Products.Where(p => p.Price < 2).ToList();

The above code is equivalent to this SQL statement:

Select * From Products Where Price < 2

I want to know is there any framework like that in Java?

I also saw https://stackoverflow.com/questions/1083080/what-are-the-java-equivalents-to-linq-and-entity-framework">quaere</a>;. But it just queries collections. I want to query against the database. There is another framework in java called http://hibernate.org">Hibernate</a> which does not provide good functionality for query the database.

Java Solutions


Solution 1 - Java

The standard ORM API in Java it's called JPA, and is part of the Java EE specification. Another alternative would be to use Hibernate. Both provide their own query language (JPQL and HQL respectively), but no query framework exists under Java that provides a direct integration at the language level the way LINQ does for C#.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSeyed Morteza MousaviView Question on Stackoverflow
Solution 1 - JavaÓscar LópezView Answer on Stackoverflow