Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between h2 vs hibernate and MySql in general sense

I am while building a spring web came to know about H2,Hibernate. Earlier while I developed android app I used sqlite or mySQL database. While using those in new platform I am little bit in a dark about difference among them.

My Current understanding is:

H2 and MySQL are both relational database management system

Hibernate is orm(object relational model)

I am little bit confused that if these three can be used in same application or these three can not be used at the same .Please let be understand plain english and with a real life example .TIA

like image 966
mubir Avatar asked Nov 19 '19 12:11

mubir


People also ask

What is the difference between H2 database and MySQL?

MySQL is a server - based database - it runs as a separate process from your application, and is commonly used in production deployments. H2 is a lightweight database, which can run entirely in-memory, or with disk storage, either in your application's process (embedded) or in a separate process.

Is H2 database and hibernate same?

In this Hibernate H2 database tutorial, you will learn how to create a Hibernate Application to connect the H2 in-memory database. Hibernate is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

What is hibernate and MySQL?

Hibernate is an ORM (Object-Relational Mapping) tool that is used to save the Java objects in the database system. As an object-oriented query language, JPA uses JPQL (Java Persistence Query Language) to execute database operations.

Is H2 and SQL same?

H2 Database and Microsoft SQL Server belong to "Databases" category of the tech stack. According to the StackShare community, Microsoft SQL Server has a broader approval, being mentioned in 697 company stacks & 2723 developers stacks; compared to H2 Database, which is listed in 9 company stacks and 19 developer stacks.


1 Answers

Yes, both H2 and MySQL are relational databases.

MySQL is a server - based database - it runs as a separate process from your application, and is commonly used in production deployments.

H2 is a lightweight database, which can run entirely in-memory, or with disk storage, either in your application's process (embedded) or in a separate process. It is most commonly used in testing scenarios, and IMHO, not suitable for most production applications.

Hibernate is an ORM, and can serve to insulate your application from the particular database that you are using, as long as you stay away from vendor-specific features.

It is common when using Hibernate and libraries built on top of it, to use a stand-alone database such as MySQL in production, and an embedded database like H2 in test, with only some configuration files changing between the two.

Since you are using Spring, it is arguably better to use Spring Data and JPA than to use Hibernate directly. Hibernate is bundled with Spring Data and serves as the JPA provider.

like image 96
GreyBeardedGeek Avatar answered Sep 22 '22 16:09

GreyBeardedGeek