Databases and Java

I am starting to write java code and interact with the databases for my project "nextbigthing". Can someone direct me to the best way to handle adding / updating tables / records in databases? Here is my problem. Too many repetitions when it comes to DB code in java. First I need to create tables (I use mysql). Then I create classes in Java for each table. Then I create AddRow, DeleteRow, UpdateRow and Search * depending on my need. For every table, every need to create this huge sql ass application and classes all seems like a huge waste of time. There must be a better, simpler and more efficient way of doing things. Is there something that I don’t know that will allow me to simply tell Java what a table is,and does it automatically generate queries and execute them for me? Its a simple SQL that can be generated automatically if it knows the column names and dependencies between tables. This seems to be very reasonable.

+3
source share
8 answers

Check out Hibernate - standard Java ORM .

+4
source

User hibernation to map your classes to the database.

Install hbm2ddl.auto to upgrade so you don't have to write DDL yourself. But note that this is not the best way to take it to production.

+3
source

Hibernate: https://www.hibernate.org/ Java CRUD .

+2

, !

Java EE , , JPA .

Java EE Sun Java EE 5. http://java.sun.com/javaee/5/docs/tutorial/doc/

4 - Beans 5 - (JPA)

Hibernate (), JPA.

Java 5 . Java 2, Hibernate iBatis.

+2

iBatis, SQL. Else JPA . Seam Framework. .

+1

(http://db.apache.org/torque/), , , .

mysql (, Postgresql, Mysql ), Torque , java . Torque Java- .

where ( Criteria, sql ) .

, , User House, 0 , getHouses(), .

, , http://db.apache.org/torque/releases/torque-3.3/tutorial/step5.html, , , // . ( , , ).

+1

, Hibernate , Spring JDBC. .

iBatis - , Spring JDBC Hibernate.

+1

. IDE .

Eclipse Java EE JPA, Dali plugin. Eclipse.org PDF-.

Eclipse Java EE " ol" Hibernate, Hibernatetools. Hibernate.org.

Both tools are capable of reverse engineering from SQL tables to full Javabeans / entities and / or mapping files. In fact, this takes away most of the headaches. When capturing JPA, the DAO sample is a little shy. In the case of Hibernate, you can use the Generic DAO .

0
source

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


All Articles