A
A
acwartz2021-08-11 11:00:17
Java
acwartz, 2021-08-11 11:00:17

Spring lookup tables how to use them?

Good afternoon!

Before that, I did not use ORM, and therefore questions arise.

There is a reference table, say the type of document + additional characteristics of a particular type.

CREATE TABLE IF NOT EXISTS `doc_types` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  UNIQUE KEY (`id`)
) DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `docs` (
  `id` int NOT NULL,
  `documentType`int NOT NULL,
  `content` varchar(200) NOT NULL,
  PRIMARY KEY (`id`,`documentType`)
) DEFAULT CHARSET=utf8;

INSERT INTO `doc_types` (`id`, `name`) VALUES
  (1, 'Внутренний оборот'),
  (2, 'Внешний оборот'),
  (3, 'Сервисный документ');

INSERT INTO `docs` (`id`, `documentType`, `content`) VALUES
  ('1', 1, 'Какой-то внутр документ'),
  ('2', 1, 'Какой-то внутр документ'),
  ('1', 2, 'Какой-то внеш документ'),
  ('1', 3, 'Какой-то сервисный документ');

There is a table-document, with a field of this type (1 piece).
those. The user selects a value from the reference book.

How does it work in spring?
the directory is also a pagingAndSorting repository and each entry is an entity?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question