Тёмный

stop using H2 in memory-database RIGHT NOW 

Amigoscode
Подписаться 925 тыс.
Просмотров 31 тыс.
50% 1

H2 is an in memory database which is misused quite a for testing. In this video I will to discuss the drawbacks of using H2 in memory database and what are the alternatives.
60h Full Stack Professional Course - amigoscode.com/courses/full-s...
Don't Forget to
===========================================
💯 Subscribe to Amigoscode - bit.ly/2HpF5V8
💯 Courses Available for free here - amigoscode.com/courses
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
🙊 Here are the goods for all my videos video 🙊
► Recommended Books
===========================================
- Clean Code - amzn.to/2UGDPlX
- HTTP: The Definitive Guide - amzn.to/2JDVi8s
- Clean Architecture - amzn.to/2xOBNXW
► Computer and Monitor
===========================================
- New Apple MacBook Pro - amzn.to/3464Mmn
- Dell 27 INCH Ultrasharp U2719D Monitor - amzn.to/2xM3nW1
- Double Arm Stand Desk Mount - amzn.to/3aYKKfs
- USB C Hub Multiport Adapter - amzn.to/2Jz7NlL
► Camera Gear
=============================================
- Sony ILCE7M3B Full Frame Mirrorless Camera - amzn.to/346QIJn
- Sigma 16 mm F1.4 DC DN - amzn.to/2wbic3Q
- Sigma 33B965 30 mm F1.4 DC DC - amzn.to/39G37Fd
► IDE & Tools I use for coding 💻 🎒
===========================================
- ITerm
- VsCode
- GoLand
- IntelliJ Ultimate
- Sublime
P.S
===========================================
💯 Don't forget to subscribe | bit.ly/2HpF5V8
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
💯 Follow me on Instagram | bit.ly/2TSkA9w
❤️ Thanks for watching

Наука

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 97   
@ChandlerBing11
@ChandlerBing11 Год назад
Hey, Nelson, you could record a tutorial teaching How to configure this AbstractTestcontainers and all that stuff to replace H2 DB. That's really useful, your videos are amazing
@user-ly5rn3cq4v
@user-ly5rn3cq4v Год назад
I would like to watch that video)
@amigoscode
@amigoscode Год назад
Will do
@netmarvintube
@netmarvintube Год назад
Good idea!!!
@stefanoriffaldi84
@stefanoriffaldi84 Год назад
@@amigoscode thanks man
@asjjain191183
@asjjain191183 Год назад
Whatever you are talking about, maybe true for complex projects or high data loads. But 90% of projects have very simple crud operations. Anyhow, it's not always about unit testing. Before going to production, usually, code is tested by QA, performance, load testing, security team and UAT. with h2 database writing test cases is easy.
@kelvinbirikorang1877
@kelvinbirikorang1877 Год назад
I still think H2 in testing is fine, if you ain't performing limited / any database-specific functions. Spinning up docker to run something simple during integration test, hmm it seems overkill
@andreiisachenko6755
@andreiisachenko6755 Год назад
Hello, Thank you for the video. I have 7+ years production expedience and want to add few moments which i learned). So better a bad test than no test). Yes h2 is not totally equal to production ready databases and what works on h2 might not work on MySql,Postgres... But it is
@MrBrackets
@MrBrackets Год назад
really great Nelson! Thank you so much for sharing. I've been following you since the beginning and I can say your content helped me a lot on my career, I'm an amigoscode fan definitely haha. I really want to buy the Full Stack Professional course but right now my budget is a little tight, would be awesome to get a magic coupon code. Thank you so much for everything, you're an inspiration to me!
@sadeepaalwis5938
@sadeepaalwis5938 Год назад
Loved the video Nelson please do a tutorial on TestContainers and setting it up a little in depth ❤ Thank you!
@sadiqshaikh8715
@sadiqshaikh8715 Год назад
Hey amigo i just wanted to let you know I got into software development recently and you have been a great help keep up the good work man❤
@pekopekohahahaha
@pekopekohahahaha Год назад
I have also encountered situations where the testing results of H2 Database and PostgreSQL are different. This video has further convinced me that H2 should not be used. Thank you for sharing.
@hotshotgolfer3079
@hotshotgolfer3079 7 месяцев назад
Love the way you teach! I just finished my first h2 todo project. But I am from PHP and MySQL so I needed some instruction on host to get a MySQL database with the JAVA project instead of H2. This was a little over my head. I am off to your website to see if you have a course that might fit my level a little better. TY!
@axslv
@axslv Год назад
While H2 is not recommended sometimes using it is the only way to have your tests. For example, the most recent client of ours provided us with their CITRIX vms, so this rendered both docker and testcontainers impossible to use. What I want to say is that we need H2 in order to cover ignorance of our clients. So again, when we have "theory" VS "real world" problem. Thanks for this video!
@RochaNahuel
@RochaNahuel 10 месяцев назад
I am studying his course from two years ago on JUnit testing and he recommends using H2, in fact he is teaching it, at that moment the thumbnail of this video came to mind, now I don't know if I should learn like this or not...?
@xbuddhi2370
@xbuddhi2370 Год назад
Perfecto Amigo, we need the tutorials on test containers and all the testing stuff in spring boot soon. Love you ❤
@rafabanasiewicz3074
@rafabanasiewicz3074 Год назад
Hey Nelson! Where can I find your code formatter setup? Also I’m staying with dillema which MacBook Pro is best For fullstack oriented programming with a budget of 2k$ (prefer 14’ ones) It will be better to buy M2 Pro or M1 Pro with upgraded RAM? Or maybe other one with Intel processor?
@michelchaghoury9629
@michelchaghoury9629 Год назад
We need more videos about testing and about Test Containers and Integration Testing. Please can you in the future make tutorials about Spring Boot Reactive?
@alaeddingarraoui4538
@alaeddingarraoui4538 Год назад
THANKS Nilson, always wonderful video ! . I'd love to make a video on how to use docker to replace H2 cos right now I'm learning it, and still I'm not quite sure to understand how to use it in a concrete project like this your project.
@aminesafi7261
@aminesafi7261 Год назад
Great content, keep going bro!
@trustDproc3ss
@trustDproc3ss Год назад
Thanks for this, this approach is good for developer using docker.
@kirasign4605
@kirasign4605 Год назад
Thank for granting my wish, amigo! I know this video is just not for me but I am also one of the people who requested it. Even in your big time of fasting 🥰
@safirahman1612
@safirahman1612 Год назад
Hi Amigoscode! I'm starting my first Java developer job in the coming month and I'm really nervous. Can you please make a video with the test setup that you have?
@kalden.s814
@kalden.s814 Год назад
Yes please make a video on testing (for controller, repository and service layer). I don't understand how to test😢 I can write code but i cannot write tests for it😑
@hovasty
@hovasty Год назад
Great video. Please show us how to do test containers :)
@georgepro8481
@georgepro8481 Год назад
Hello, Nelson! Is it possible to launch testcontainers automatically before tests start? And stop it after?
@elhadjbabacarcisse2868
@elhadjbabacarcisse2868 Год назад
Hello Nelson, thanks as usual. Can you make a video on TestContainers and your configuration? Thanks mate
@geni4551
@geni4551 Год назад
Thank you. Would love to see the TestContainers video
@shayuru
@shayuru Год назад
It sounds fine, but it works on the Development environment (local), but this cannot be easily done over automated CI/CD, e.g. Jenkins or GitHub Actions, it is possible but requires extra resources and configuration and create a dependency on the database (must be running before the test), UTs are supposed to be isolated. that's why mock libraries were created, I understand your point I've created UTs that run against a "real" database, but I've disabled them when running the automated CI/CD because I cannot modify the "DevOps infrastructure" just to run containers.
@andresnator
@andresnator Год назад
Thanks for your videos
@ainigma100
@ainigma100 Год назад
Thank you for the great video!
@gaetanbayenay8730
@gaetanbayenay8730 Год назад
Hi, Just a quick comment... In general in Java world, you should use JPA and Hibernate (or similar) to handle DB. So, as far as you're using this abstraction, there is no big deal to use H2. And by the way, the use of custom DB functions is discouraged. Better to stay with "standard SQL" (or similar from Hibernate). So it means it's perfectly safe to use H2 to make some kind of unit tests, for instance those that ensure the correct lazy loading or the persistence effectiveness, your real (basic)persistence logic, etc... And it's not replacing integration tests with whatever DB you want... An advantage to H2, is the possibility to launch directly some SQL script in the connection String. That way, you can initialize a database correctly (with specific SQL like the one that was created by the DBA). True story, if I was not trying to use H2 on one of the project I collaborated, then I never been able to detect fundamental PROD DB problem. It was precisely because I forced myself to standardize things through JPA and Hibernate, and validated both local H2 and other environment Oracle that I found some previous migration was not completed correctly... I'll not advocate to use H2, I'll just wanted to say it's another great tool that can be used. It's a little unfair to say it's not safe, if you pay attention to the limitations...
@maksym.pavlenko
@maksym.pavlenko Год назад
Correct me if I'm wrong, but in case if I cannot avoid using a feature provided by a custom DB function, I'd use it, rather than inventing a wheel by implementing it myself and putting a responsibility of supporting this logic on my team
@gaetanbayenay8730
@gaetanbayenay8730 Год назад
@@maksym.pavlenko, I'll say that you can maybe challenge the real necessity to have the custom DB function. And well, if it's really not possible to do without this custom function, then there is no reason to not use it. It's just that you can "skip" the particular part that use the custom function by skipping the H2 test, and try to have unit tests / integration tests with H2 for everything else. Then it's a matter of isolation, more than avoiding custom DB functions.
@maksym.pavlenko
@maksym.pavlenko Год назад
@@gaetanbayenay8730 all this comes from unreliability of such functions or the fact the migration to another DB without unsupported functions could be easier?
@gaetanbayenay8730
@gaetanbayenay8730 Год назад
@@maksym.pavlenko I think it's more complex than that. If the goal is to have the ability to change DB, then the standardization is a must. So, higher expectation means to think about the problem (and the way the data are stored) differently. It's not only the pure data, or the way to handle them, but also the meaning of the data organization. That's the reason why it's important to challenge the real need for custom function. Another point is how to deal in code with the data. If a custom function can be avoided by using similar data manipulation within Java (for instance with java streams), or by rethinking the separation of concerns with a split into microservices, then it's also a valid answer to the problem. And maybe it's the DB technology itself that can be changed (by using non relational DB, or something totally different). So, there is room to avoid custom functions, depending on the needs and the liberty in adressing the problem... :) ... But at the end, if the functions exists, there is a need too, and good reasons to use them, with the knowledge that the code is no more standardized.
@marianacagnoni3205
@marianacagnoni3205 Год назад
we're all waiting for the testing containers tutorial sir thanks for the good content!
@patryktraczyk3246
@patryktraczyk3246 11 месяцев назад
AbstractTestcontainers would be really great to see! Hope you can prepare such material soon 😀
@jqwerty296
@jqwerty296 Год назад
Hi Yes we need this video about containers.
@pierrelaurensflorez2273
@pierrelaurensflorez2273 Год назад
Hey Nelson! Good video. I would like to see a TestContainer tutorial on using it, and I have a quick question. If I'm using an interface that implements JPARepository without using custom queries, should I need to write unit test for the original operations? Should I test the interface? Or should I create a class that implements my custom interface and then create a unit test for this new class? I really appreciate this video Nelson!!
@felipepedrosa6220
@felipepedrosa6220 Год назад
Isn't necessary to test this JPA interfaces, You'll need to test it just in case of having custom queries. All "default" queries are tested over years by spring community :)
@aleksandarivanov8824
@aleksandarivanov8824 Год назад
Great video! I would like if you could put a video from scratch about test containers.
@slota4
@slota4 Год назад
yes, please make some example how to setup TestContainers, how to use it :) will be helpful for sure.
@zakharborisov1841
@zakharborisov1841 Год назад
Should I mock repository in service layer? If I tested custom queries of repository using testcontainers?
@0107007
@0107007 Год назад
Hi! What do you think about using SQLite as an alternative to H2? I know it has similar limitations but if the application is small or simple it may works well, right?
@johndoedoejohn
@johndoedoejohn Год назад
I guess mongoDb would be good option with mongo atlas, but it's nosql
@user-go7iy8gy2t
@user-go7iy8gy2t Год назад
yes, we want to see how to use testcontainers from scratch, plz
@adrianilie28
@adrianilie28 Год назад
Yes! Please! I'm interested in Testcontainers :)
@bryceblankinship
@bryceblankinship Год назад
Ran into this at work recently. H2 dialect for Oracle isn’t complete and it was literally impossible to test my DAO and had to mock it… which is useless!
@danielkirsch4351
@danielkirsch4351 Год назад
Awesome Nelson, testcontainers vid pleeeese!😊
@hetman78182
@hetman78182 Год назад
I would also like to watch a video about testcontainers, especially with spring boot 3.1
@tarikmujcic2966
@tarikmujcic2966 Год назад
It would be REALLY good to have the video on test containers
@akashranjan930
@akashranjan930 Год назад
Hey Nelson! can you make tutorial on SpringAOP, couldn't really find any perfect explanation
@sirfinsaan
@sirfinsaan 3 месяца назад
what about external service ? should we mock or any other approach
@zhandosyernazarov3086
@zhandosyernazarov3086 Год назад
Hi, I would love to see a video on setting up TestContainers
@ammanul543
@ammanul543 Год назад
Hi i had one doubt can't we use mockito instead of actual database call?
@xSferQx
@xSferQx Год назад
I mean, this is why we use abstraction. DBs might have differences, but we should develop app as flexible as possible. So using H2 is good if it’s justified. If we use some specific function from PostgreSQL in out test, maybe we should consider changing it
@pasvupaspris303
@pasvupaspris303 6 месяцев назад
solid point
@MarcioJustoDev
@MarcioJustoDev Год назад
Please Nelson! A video for testcontainers, including with kafka reactive! hands 🙏🏾
@Muescha
@Muescha Год назад
please do a deep dive tutorial into testcontainers
@zakariaeelbouayadi3222
@zakariaeelbouayadi3222 Год назад
Assalamu alaykum and Thank you very much
@simbarashemaunga5575
@simbarashemaunga5575 Год назад
This may trigger someone but I say it in good faith. Consider setting a poll on whether or not you should continue with these new thumbnails where you look shocked/confused etc vs the legendary thumbs up.
@NakMs
@NakMs Год назад
For the container db test, it quite take time when run.
@RochaNahuel
@RochaNahuel 10 месяцев назад
You should update your JUnit course from 2 years ago where you literally recommend using H2 , or add some notification in that video.
@Muescha
@Muescha Год назад
how you have automated the firework at the end of the tests?
@DevLearn-lv7nr
@DevLearn-lv7nr 4 месяца назад
H2 is absolutely fine for QUCK testing, without going to the effort of a "near to production as possible" environment
@arturxavier1481
@arturxavier1481 Год назад
But how would I setup the docker in a CI environment?
@azeemcr37
@azeemcr37 Год назад
Need TestContainers video 🔥🔥🔥🔥
@FredrickIrubor
@FredrickIrubor Год назад
Docker is a life saver
@zombi1034
@zombi1034 3 месяца назад
Easy solution. Just use H2 in production😎
@marcosdantasguimaraesfilho7747
Please do record a video on setting up TestContainers! That's soooo useful!!
@radecki125
@radecki125 Год назад
we want to see testcontainers!
@zhenka1982
@zhenka1982 Год назад
I am a principal software engineer. I like a lot of your videos and give you props for explaining best practices to junior engineers in a clear and concise way. However, this video is an exception. Judging by the comments, nobody really understood your point. And I must say, your point is lost because for some reason you are talking about H2 and “in memory-database” like that’s something special. The only sensible thing you can say is that a test environment should as closely as possible mimic the production environment. Now that’s a true statement. What does H2 in particular have to do with the price of tea in china? Same would be true if you said “Don’t use Oracle to test MySQL queries”. Now, I get it, you are trying to say, that the ease of getting an H2 running makes it super easy to use for testing. But that’s largely irrelevant, for the point you are trying to make.
@darioanguilla3147
@darioanguilla3147 Год назад
Testcontainers deeply from scratch please!
@Rostik_13
@Rostik_13 Год назад
"How to configure this AbstractTestcontainers and all that stuff to replace H2 DB?" Just do it, please😎👊
@maulikdavra389
@maulikdavra389 10 месяцев назад
Dear Nelson If you are opposing of using H-2 in first place then why haven't you updated your course "software testing" (listed on your website) which uses H-2 db. On top of that throughout the course you are mocking repository layer and injecting mock on service layer. If this is not the best practice to follow then why you haven't you updated this course with docker implementation. H-2 is quite good with basic CRUD operations but docker is one of the safe and reliable option for testing. Please record a video for unit as well integration testing with docker test containers. At least this would help me learn all the major concepts of software testing. But I am still not clear if mocking service layer or repository layer is OK for isolation testing or even unit as well as integration testing! what type of testing practices an enterprise company follows ?
@MrBgdu26
@MrBgdu26 Год назад
That’s cool but when I try it on my PC, with an Oracle test container, it takes 2 minutes to run a single test
@IndritVaka
@IndritVaka 7 месяцев назад
The video was great, but why you have to add that rainbow??
@antonpirulero2836
@antonpirulero2836 Год назад
Why? h2 is excellent to teach the basic of SQL without messing with a db install. H2 is not designed for a production serious enviroment. Learn the basic of ORM, SQL, JDBC and then kick off the H2 if you want.
@fernandorivera4719
@fernandorivera4719 Год назад
I have been trying for weeks to create the simplest application: something that creates users and saves it into an H2 database. But for some godforsaken reason, all POST requests made to the register endpoint return a status 200 instead of a 201, so nothing is ever created on the database. Why? I have asked everyone, from teachers and professionals, to chat GPT and no one seems to find the answer. I'm beginning to think the issue may be related somehow to the H2 database. I see no other explanation.
@antonpirulero2836
@antonpirulero2836 Год назад
@@fernandorivera4719 ... its a conspiracy ...
@felipe1876
@felipe1876 Год назад
Ok. I promise that. Can you hire me?
@maximilianh7728
@maximilianh7728 Год назад
hey amigoo
@LifeOfMohammed
@LifeOfMohammed Год назад
This is not ideal for tests though as with tests I run them on an environment that doesn't have a database instead just uses the memory database
@togerait
@togerait Год назад
The H2 technology is used by many book authors to explain concepts. I have never liked this foolish approach, and I am happy to see someone who thinks like me for the first time.
@ayoubelhioui2205
@ayoubelhioui2205 6 месяцев назад
is that means H2 has no use cases? can you explain why did you call it foolish approach?
@trocandobytes
@trocandobytes Год назад
What about SQLite ?
@tepchiva8342
@tepchiva8342 2 месяца назад
Could you please publish source code?
@daniel_goncalves
@daniel_goncalves Год назад
Show how tô do this
@nandux586
@nandux586 Год назад
Hey man. I appreciate your content, but the thumbnails are kind of off putting. 😬
@sadiqshaikh8715
@sadiqshaikh8715 Год назад
Second🎉
@Abrahhhhh
@Abrahhhhh Год назад
First🎉🎉🎉
@user-mg1mk5on3l
@user-mg1mk5on3l Год назад
You can have his course for free. Dont buy his overpriced course
@NEMOBANDZBEATS
@NEMOBANDZBEATS Год назад
If you get a lot of value from his content why not show some support ?
@haltsmaul.
@haltsmaul. Год назад
I'm developing a small application that uses an H2 DB and got real spooked 😳.
@AndriiKovalov
@AndriiKovalov Год назад
I agree that nowdays it is a best practice to use testcontainers to have best compatibility across all environments. But for those who stuck with H2 for any reason, keep in mind that you have some flexibility by creating aliases for Java based functions, ie: CREATE ALIAS IF NOT EXISTS TRUNC FOR "my.package.MyH2Functions.trunc";
Далее
10 Most Common Java Developer Mistakes
16:13
Просмотров 100 тыс.
🎙Пою Вживую!
2:59:56
Просмотров 1,2 млн
What the Heck is an In Memory Data Grid | Pivotal
28:22
H2 Database Basics
10:30
Просмотров 32 тыс.
15 futuristic databases you’ve never heard of
8:42
Просмотров 642 тыс.
the right way to organise your code
17:33
Просмотров 190 тыс.
NEVER Write This Line Of Code In Production. Seriously
13:21
The cleanest way to use Docker for testing in .NET
13:36
Functional Programming with Java Streams API
50:00
Просмотров 171 тыс.
How charged your battery?
0:14
Просмотров 2,7 млн
Мой странный компьютер 2024
18:33
What’s your charging level??
0:14
Просмотров 7 млн