Похожие чаты

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 ответов

26 просмотров
ᅠ ᅠ ᅠ 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 👍😀

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта