M
M
Makari4DM2014-03-30 13:50:46
Java
Makari4DM, 2014-03-30 13:50:46

Java - how to implement automatic generation of classes from a database?

Please tell me a library or method for automatically generating Java classes from a database, taking into account external and internal keys. Example:
From this SQL code:

CREATE TABLE T1
(
    ID INT PRIMARY KEY NOT NULL,
    string_value CHAR(100)
);

CREATE TABLE T2
(
    ID INT PRIMARY KEY NOT NULL,
    string_value CHAR(100),
    T1_rec INT NOT NULL    
);
ALTER TABLE T2 ADD CONSTRAINT FK_T1_TO_T2
  FOREIGN KEY (T1_rec) REFERENCES T1 (ID) ON UPDATE CASCADE ON DELETE CASCADE;

Convert to this Java code:
class T1Record
{
  public int ID;
  public String string_value;
}
class T1Table
{
  public Insert(T1Record rec)
  public Update(T1Record rec)
  ...
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Lopatin, 2014-03-30
@Makari4DM

Hibernate Reverse Engineering .
Tutorial is here . But you can also google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question