Mapping tables from an existing database to an object - is Hibernate suitable?

I have several tables in an existing database and I want to map them to a Java object. In fact, this is one table that contains basic information, some other tables that refer to such a table entry with a foreign key.

I do not want to store objects in the database, I just want to read them. The program should not be allowed to apply any changes to the underlying database.

I am currently reading from a database with 5 SQL JDBC queries and setting the results then to an object.

Now I am looking for less intensive code. Another goal is the educational aspect. Is Hibernate suitable for this task or is there another ORM framework that better suits my requirements?

+3
source share
3 answers

I have several tables in an existing database and I want to map them to a Java object. In fact, this is one table that contains basic information, some other tables that refer to such a table entry with a foreign key.

Sounds like a standard circuit, Hibernate should be able to handle it without a problem.

I do not want to store objects in the database, I just want to read them. The program should not be allowed to apply any changes to the underlying database.

Hibernate supports “immutable” objects (immutable objects cannot be updated by the application, see @Immutableannotation).

5 SQL- JDBC .

, , , ...

. - . Hibernate ORM, ?

, . , , Hibernate - ( , , iBATIS, ) Hibernate/JPA . , , lazy-load, 2- .

+2

. , , .

+1

If you are looking for a simpler hibernation solution, you can check out ORMLite, which is a [very] simple ORM package. I used it to read in objects from existing SQL tables with great success.

http://ormlite.com/

0
source

Source: https://habr.com/ru/post/1747347/


All Articles