Похожие чаты

Guys, can someone suggest me, please, the way how to

fix the problem with h2?

I have DTO:
https://gist.github.com/invzbl3/18bcb8823aaae64a236de2d4636dbe0c

and Entity:
https://gist.github.com/invzbl3/ca9b734a15202d0bd3f39cc013dd6508

I'm trying to save entity after convertation from dto into h2 database using JPA by the principle:

repo.save(entity)

my application.properties file:
https://gist.github.com/invzbl3/4de704993b2bb5766e4871b7b7f16a21

The problem is: h2 database doesn't have any data in Data Source, but in console I see:

https://gist.github.com/invzbl3/84e953032f65e9d8cea26aa50816de07


P.S. I'm reloading database using Refresh via command Ctrl+F5 and still no data in db.

13 ответов

7 просмотров
ᅠ ᅠ ᅠ Maksym-R. Автор вопроса

I don't quite understand why it happens if frameworks like Spring Boot can be configured to perform Database Initialisation

How do you know that the DB does not have data?

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса
Roy
How do you know that the DB does not have data?

I check own database inside data source

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса

problem solved, it was related to configuration file👍

It's not clear where exactly that save call happens. And when exactly you check database state. save(entity) may not necessarily right away result in db insert. Google for something like "hibernate session", "jpa entity states", " jpa entity manager". https://www.baeldung.com/spring-data-jpa-save-saveandflush

ᅠ ᅠ ᅠ Maksym R.
problem solved, it was related to configuration fi...

😁😁😁 right a few seconds before I posted my idea)))

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса
Dmytro Buryak
It's not clear where exactly that save call happen...

I've checked database in Data Source using refresh after sending request in postman and see in console that hibernate insert data, as you can on the screen

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса
ᅠ ᅠ ᅠ Maksym R.
I've checked database in Data Source using refresh...

Yes, inserts were in the last link, which I obviously was too lazy to click)))

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса
Dmytro Buryak
Yes, inserts were in the last link, which I obviou...

I thought that in-memory can show me data which hibernate insert, but it doesn't work until I changed to jdbc:h2:file mode

ᅠ ᅠ ᅠ Maksym R.
but in-memory was bad idea for saving entity))

Not at all. Bad idea is to use one db for tests, and completely other for prod. I'm 100% sure you won't use h2 ever in any real product

ᅠ ᅠ ᅠ Maksym-R. Автор вопроса
Dmytro Buryak
Not at all. Bad idea is to use one db for tests, a...

Yeah, agree. It's test task, so everything is ok 👍😀

Похожие вопросы

Обсуждают сегодня

коллеги привет. уже второй день бьемся об заклад с одной ошибкой, может вы сталкивались с таки странным поведением? есть тестовый сервер, на который паблишим релизную версию W...
Magzhan
11
Какие дистрибутивы Linux чаще всего работают в качестве серверов и почему?
Alex
27
Комрады, посоветуйте, куда копать? Стал прикручивать кастомизацию тем. В OnShow главной главной формы пытаюсь загрузить из файла настроек и применить тему (на скрине, как долж...
Ed Doc
13
Такс, блин, таки кто-то знает, каким образом работают макросы stdin/stdout/stderr? Я влез в stdio.h, там определения нет, отладил через асмокод - вызывается функция со странны...
The Bird of Hermes
18
OnShow один раз вызывается? или возможен Hide?
Iluha Companets
14
А кто-то пробовал, уезжая из Эстонии получить э-рез и продолжить вести предпринимательскую деятельность внутри Эстонии, используя свой OÜ?
Lalalashechki Lalala
62
Ребят, привет! Я портируюсь с войда на генту Читаю гентувики В разделе про разбивку диска указана xfs файловая система, а не ext4, как обычно Xfs имеет какие-то преимущества ...
Андрей Дыбов
21
Why are you encouraging people to speculate on the token in lido price instead of telling them its a voting token that has no value? Surely the channel should be closed
Sam
9
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Lol is just wrote a long text about tokenomics etc and it was directly deleted, no curses or similar so i write it again in shorter. Hey Ben 600m eco system tokens, around 30...
. Duss
7
Карта сайта