stop using H2 in memory-database RIGHT NOW

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 96

  • @ChandlerBing11
    @ChandlerBing11 Год назад +100

    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

  • @asjjain191183
    @asjjain191183 Год назад +9

    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 Год назад +7

    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 Год назад +3

    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

  • @pekopekohahahaha
    @pekopekohahahaha Год назад +1

    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.

  • @sadeepaalwis5938
    @sadeepaalwis5938 Год назад +12

    Loved the video Nelson please do a tutorial on TestContainers and setting it up a little in depth ❤ Thank you!

  • @axslv
    @axslv Год назад +3

    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 Год назад

      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...?

  • @hotshotgolfer3079
    @hotshotgolfer3079 Год назад +1

    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!

  • @kalden.s814
    @kalden.s814 Год назад +2

    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😑

  • @michelchaghoury9629
    @michelchaghoury9629 Год назад +2

    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?

  • @gaetanbayenay8730
    @gaetanbayenay8730 Год назад +12

    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.

  • @RzariRzari
    @RzariRzari Год назад +1

    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

  • @xbuddhi2370
    @xbuddhi2370 Год назад +1

    Perfecto Amigo, we need the tutorials on test containers and all the testing stuff in spring boot soon. Love you ❤

  • @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!

  • @kirasign4605
    @kirasign4605 Год назад +1

    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 🥰

  • @MrBrackets
    @MrBrackets Год назад +1

    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!

  • @shayuru
    @shayuru Год назад +2

    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.

  • @arvikv
    @arvikv Год назад +2

    yes, we want to see how to use testcontainers from scratch, plz

  • @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❤

  • @geni4551
    @geni4551 Год назад +1

    Thank you. Would love to see the TestContainers video

  • @DevLearn-lv7nr
    @DevLearn-lv7nr 9 месяцев назад

    H2 is absolutely fine for QUCK testing, without going to the effort of a "near to production as possible" environment

  • @jqwerty296
    @jqwerty296 Год назад +1

    Hi Yes we need this video about containers.

  • @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?

  • @hovasty
    @hovasty Год назад +2

    Great video. Please show us how to do test containers :)

  • @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.

  • @trustDproc3ss
    @trustDproc3ss Год назад

    Thanks for this, this approach is good for developer using docker.

  • @georgepro8481
    @georgepro8481 Год назад

    Hello, Nelson! Is it possible to launch testcontainers automatically before tests start? And stop it after?

  • @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.

  • @hetman78182
    @hetman78182 Год назад +1

    I would also like to watch a video about testcontainers, especially with spring boot 3.1

  • @slota4
    @slota4 Год назад

    yes, please make some example how to setup TestContainers, how to use it :) will be helpful for sure.

  • @marianacagnoni3205
    @marianacagnoni3205 Год назад

    we're all waiting for the testing containers tutorial sir
    thanks for the good content!

  • @RochaNahuel
    @RochaNahuel Год назад

    You should update your JUnit course from 2 years ago where you literally recommend using H2 , or add some notification in that video.

  • @tarikmujcic2966
    @tarikmujcic2966 Год назад

    It would be REALLY good to have the video on test containers

  • @sirfinsaan
    @sirfinsaan 9 месяцев назад

    what about external service ? should we mock or any other approach

  • @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 Год назад +1

      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 :)

  • @zakharborisov1841
    @zakharborisov1841 Год назад

    Should I mock repository in service layer? If I tested custom queries of repository using testcontainers?

  • @elhadjbabacarcisse2868
    @elhadjbabacarcisse2868 Год назад

    Hello Nelson, thanks as usual. Can you make a video on TestContainers and your configuration? Thanks mate

  • @NakMs
    @NakMs Год назад

    For the container db test, it quite take time when run.

  • @zhandosyernazarov3086
    @zhandosyernazarov3086 Год назад

    Hi, I would love to see a video on setting up TestContainers

  • @MarcioJustoDev
    @MarcioJustoDev Год назад

    Please Nelson! A video for testcontainers, including with kafka reactive! hands 🙏🏾

  • @patryktraczyk3246
    @patryktraczyk3246 Год назад

    AbstractTestcontainers would be really great to see! Hope you can prepare such material soon 😀

  • @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 11 месяцев назад

      is that means H2 has no use cases? can you explain why did you call it foolish approach?

  • @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

  • @adrianilie28
    @adrianilie28 Год назад

    Yes! Please! I'm interested in Testcontainers :)

  • @aleksandarivanov8824
    @aleksandarivanov8824 Год назад

    Great video! I would like if you could put a video from scratch about test containers.

  • @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.

  • @aminesafi7261
    @aminesafi7261 Год назад

    Great content, keep going bro!

  • @akashranjan930
    @akashranjan930 Год назад

    Hey Nelson! can you make tutorial on SpringAOP, couldn't really find any perfect explanation

  • @ammanul543
    @ammanul543 Год назад

    Hi i had one doubt can't we use mockito instead of actual database call?

  • @antonpirulero2836
    @antonpirulero2836 Год назад +1

    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.

    • @TheUrizen
      @TheUrizen Год назад

      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 Год назад

      @@TheUrizen ... its a conspiracy ...

  • @Muescha
    @Muescha Год назад

    please do a deep dive tutorial into testcontainers

  • @maulikdavra389
    @maulikdavra389 Год назад +1

    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 ?

  • @zombi1034
    @zombi1034 9 месяцев назад

    Easy solution. Just use H2 in production😎

  • @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

  • @Muescha
    @Muescha Год назад

    how you have automated the firework at the end of the tests?

  • @Rostik_13
    @Rostik_13 Год назад

    "How to configure this AbstractTestcontainers and all that stuff to replace H2 DB?"
    Just do it, please😎👊

  • @danielkirsch4351
    @danielkirsch4351 Год назад

    Awesome Nelson, testcontainers vid pleeeese!😊

  • @ainigma100
    @ainigma100 Год назад

    Thank you for the great video!

  • @radecki125
    @radecki125 Год назад

    we want to see testcontainers!

  • @arturxavier1481
    @arturxavier1481 Год назад

    But how would I setup the docker in a CI environment?

  • @azeemcr37
    @azeemcr37 Год назад

    Need TestContainers video 🔥🔥🔥🔥

  • @darioanguilla3147
    @darioanguilla3147 Год назад

    Testcontainers deeply from scratch please!

  • @andresnator
    @andresnator Год назад

    Thanks for your videos

  • @FredrickIrubor
    @FredrickIrubor Год назад

    Docker is a life saver

  • @IndritVaka
    @IndritVaka Год назад

    The video was great, but why you have to add that rainbow??

  • @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

  • @trocandobytes
    @trocandobytes Год назад

    What about SQLite ?

  • @zakariaeelbouayadi3222
    @zakariaeelbouayadi3222 Год назад

    Assalamu alaykum and Thank you very much

  • @haltsmaul.
    @haltsmaul. Год назад

    I'm developing a small application that uses an H2 DB and got real spooked 😳.

  • @tepchiva8342
    @tepchiva8342 8 месяцев назад

    Could you please publish source code?

  • @felipe1876
    @felipe1876 Год назад

    Ok. I promise that. Can you hire me?

  • @marcosdantasguimaraesfilho7747

    Please do record a video on setting up TestContainers! That's soooo useful!!

  • @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. 😬

  • @maximilianh7728
    @maximilianh7728 Год назад

    hey amigoo

  • @Abrahhhhh
    @Abrahhhhh Год назад

    First🎉🎉🎉

  • @sadiqshaikh8715
    @sadiqshaikh8715 Год назад

    Second🎉

  • @AmigoscodeFree
    @AmigoscodeFree Год назад

    You can have his course for free. Dont buy his overpriced course

    • @NEMOBANDZBEATS
      @NEMOBANDZBEATS Год назад +3

      If you get a lot of value from his content why not show some support ?

  • @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";