Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any entity framework equivalent in java? [closed]

Tags:

java

.net

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 quaere. But it just queries collections. I want to query against the database. There is another framework in java called Hibernate which does not provide good functionality for query the database.

like image 715
Seyed Morteza Mousavi Avatar asked Mar 27 '13 18:03

Seyed Morteza Mousavi


People also ask

Does Java have anything like LINQ?

In . NET, an easy way for you to simplify querying datasets is LINQ. Java doesn't have this, but since the introduction of Java 8 in 2014, you do now have the possibility to use "streams". Both LINQ and streams are ways to simplify querying datasets and to provide developers with an easy API to use.

Is Entity Framework similar to Hibernate?

nHibernate supports all types of databases but Entity framework need additional connectors to support databases other than MSSQL. nHibernate can be extended in terms of data loading, SQL generation, custom column types, custom collections etc but entity framework has limited extension points.

Which is better NHibernate or Entity Framework?

EF Core can use a ROWVERSION/TIMESTAMP column on SQL Server, or any of a list of columns, when updating a record. NHibernate offers richer capabilities, besides SQL Server ROWVERSION/TIMESTAMP, it can also use database native mechanisms such as Oracle's ORA_ROWSCN, but also timestamp or version columns.


1 Answers

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#.

like image 145
Óscar López Avatar answered Sep 22 '22 17:09

Óscar López