Spring Tips: Spring Data JDBC

  Рет қаралды 16,545

SpringDeveloper

SpringDeveloper

4 ай бұрын

Hi, Spring fans! In this installment, Josh Long looks at the fantastic Spring Data JDBC project, which is one of the easiest and most powerful ways to leverage JDBC in a Spring Boot application. #postgresql #java #springboot #jdbc #architecture #code #java21

Пікірлер: 37
@arnaudpoutieu1331
@arnaudpoutieu1331 4 ай бұрын
Thanks, Josh. Software solutions design/architecture should always be guided by "Make it Simple" attitude in priority! You rock man
@joachimdietl6737
@joachimdietl6737 4 ай бұрын
Please Josh do some tutorial about composed primary keys and this embededable thing. I think many devs are looking for it
@zakb.7108
@zakb.7108 4 ай бұрын
Care to see as well how strategies can be implemented with spring batch. For one thing using lazy loading and batch size for the entities in the first level cache seems pretty handy to me..
@mondikoci2966
@mondikoci2966 4 ай бұрын
Thanks for the demo.
@vijaydeenanth
@vijaydeenanth 3 ай бұрын
I use hibernate to persists data and use it to read data back where i need to fetch by id to update. Other than that all views are Sql Coded in mybatis. I like the approach that gives me full control on sql when I have multiple joins. I dont get compile time type safety in mybatis, but my tests help to remove any errors that might arise in runtime
@levenchen9692
@levenchen9692 4 ай бұрын
Thanks,Josh. What's is uao command?
@johng.weller468
@johng.weller468 Күн бұрын
The Profile field is not embedded inside the Customer object; how is it possible to save both of them with one repository using spring data jdbc?
@zakb.7108
@zakb.7108 4 ай бұрын
What about Mybatis? We are using it in my current position but I don't know to which extent can we mix both for repositories
@garethbaker5179
@garethbaker5179 Ай бұрын
How would you import this project into a spring-boot project such that spring-boot doesnt demand that the classes in your JdbcApplication have to be defined as Beans?
@v.deepak
@v.deepak 4 ай бұрын
I tried to explain this to everyone, nobody paying attention, they are happy with hibernate complexity 😢
@javasoccernut
@javasoccernut 4 ай бұрын
It isnt that complex. Spring Data JDBC has its own complexities. Trade offs.
@coffeesoftware
@coffeesoftware 4 ай бұрын
100%. If you truly have the sprawling complexity where Hibernate makes sense, then by all means use spring data jpa. But for most of us, there’s JavaOOQ, MyBatis, Spring Data JDBC, etc., all of which cost less in terms of performance and give us as good or better simplicity upfront. The nice thing about Spring Data is that the boring stuff looks basically the same if you ever need to move to JPA. You’d only have to worry about the complexity of entities and queries
@dominikseljan3043
@dominikseljan3043 4 ай бұрын
I wish we move away from hibernate but I don’t think that’s going to happen any time soon
@javasoccernut
@javasoccernut 4 ай бұрын
​ugh, lost my reply. Short version. this is opinion and theory. I have decades of hands on real world experience that says otherwise. I use JPA with small and large apps. Works great. It is performant. But I dont treat it like an Object Database. The issue is that people dont learn to use the tools wisely and blame the tool. We swtiched from JPA to JDBC and it was not a minor change though still easier with Spring Data and we had flat models. It wasnt more peformant. the things you meantioned are options but ones MMV. there are trade offs
@shashankbajpai5659
@shashankbajpai5659 Күн бұрын
Can you provide your schema somewhere so that we can easily follow your tutorial?
@drewenia
@drewenia 3 ай бұрын
What keyboard are you using? And keyboard switches?
@antonsiniaiev1151
@antonsiniaiev1151 4 ай бұрын
Does data jdbc support composite primary keys and json fields?
@macctosh
@macctosh 2 ай бұрын
no support for composite primary keys
@essamal-mansouri2689
@essamal-mansouri2689 4 ай бұрын
Do you recommend that people use this and not use reactive drivers and all that anymore now that we have loom
@javasoccernut
@javasoccernut 4 ай бұрын
the spring docs say (or use to) that for most apps reactive is mostly YAGNI and adds complexity. That is my experience over the decades. Code for maintenance. Optimize where needed.
@suikast420
@suikast420 4 ай бұрын
21:00 if using chances in java , then do not use the default serilizer of java.
@DuongTran-zh6td
@DuongTran-zh6td 4 ай бұрын
spring kafka teacher oi,
@essamal-mansouri2689
@essamal-mansouri2689 4 ай бұрын
You should consider jooq instead of jdbc. You wouldn't be getting "bad sql" errors at runtime like you got and it is also not using reflection, etc. and you are no longer limited to the crud operations that you are limited to here
@javasoccernut
@javasoccernut 4 ай бұрын
what are the Cons?
@dominikseljan3043
@dominikseljan3043 4 ай бұрын
Cons are that it’s expensive as hell if you are not using an open source DB
@javasoccernut
@javasoccernut 4 ай бұрын
if someone wants this, they can use ...i forget the name right now, but it can generate query models and it works with SPring Data and is true opensource.
@javasoccernut
@javasoccernut 4 ай бұрын
I'd love to share this Josh but the comments about Hibernate are not accurate. I've done RDBMS without and with Hibernate for 30 years. I don't want to go back. That being said, where there are issues is when you have an existing db that is poorly designed. Recently I had to switch to Spring Data JDBC because of this. But only because Hibernate made some change that seems to cache data types and our db deployments are not consistent and so it would occasionally blow up queries.This is not Hibernate's fault.
@olivierboisse1678
@olivierboisse1678 4 ай бұрын
19:36 cheating 😄
@remek712
@remek712 4 ай бұрын
All those things that you explained will be in future automatically handled by AI
@andreiz82
@andreiz82 4 ай бұрын
Data JPA should still be the default for most medium to big apps. Using Data JDBC may be premature optimization.
@holothuroid9111
@holothuroid9111 4 ай бұрын
You say "should". Care to explain that value judgement?
@javasoccernut
@javasoccernut 4 ай бұрын
In my humble experience (3 decades) this is the case. YMMV.
@bariole
@bariole 4 ай бұрын
No it shouldn't. You should be able to explain why you need Hibernate. Majority of time Hibernate is net negative when compared to JDBC. You end up with more code, and worse problems.
@javasoccernut
@javasoccernut 4 ай бұрын
​@@bariole that is theory or your experience. Spring Data JDBC is not just JDBC. If you do raw Hibernate, potentially. But ORMs exist to reduce the code you'd need to write without it. We just converted from Spring Data JPA to Spring Data JDBC. It was not less code. FWIR it was more. If we had not treated JPA as a table mapper, it for sure would have been.
@bariole
@bariole 4 ай бұрын
@javasoccernut Experience. Properly written Hibernate results in more code, as you need a lot of code to handle level 1 cache issues and navigate the idiosyncrasies of the context-dependent grammar of JPA/Hibernate mapping. You also need to enforce a bunch of rules, such as updates from the root, which can be challenging to explain to users who "just need SQL," etc. For the majority of people, merges seem to work like "magic." Additionally, if the application is written by relatively inexperienced individuals (which is why you are here fixing it), it will likely contain more queries than necessary, regardless of whether they are SQL or HQL. However, it is much easier to clean up directly mapped code, such as ActiveRecord, JDBC, JdbcTemplate, or MyBatis. In my 20 years of experience, I have encountered maybe five projects where the ObjectMapper pattern implementation made sense, primarily due to practical reasons such as "I need to generate SQL for multiple backends," "I need optimistic locking," or "I am using JHipster, and that is what it uses." Even Martin Fowler, the person who invented the whole pattern, stated back in 2012 that the way to fix ORMs is by keeping your model flat and in a direct one-to-one mapping with rows. Essentially, this involves fully ignoring relation mapping and relegating Hibernate's role to a "SQL generator." This approach is similar to what is presented here but without all the double-state management issues of ORMs. Most of the time, Hibernate/JPA/EclipseLink are more complex than the problems they are trying to solve.
Spring Tips: DataSources
57:40
SpringDeveloper
Рет қаралды 12 М.
Spring Tips: Virtual Threads
50:31
SpringDeveloper
Рет қаралды 4,5 М.
Uma Ki Super Power To Dekho 😂
00:15
Uma Bai
Рет қаралды 57 МЛН
Chips evolution !! 😔😔
00:23
Tibo InShape
Рет қаралды 29 МЛН
Spring Office Hours S3E3: Spring Data JPA vs JDBC vs REST
1:03:06
SpringDeveloper
Рет қаралды 4,4 М.
Spring Tips: The Spring Authorization Server
22:21
SpringDeveloper
Рет қаралды 13 М.
Spring Tips: Spring's Application Event Subsystem
20:23
SpringDeveloper
Рет қаралды 12 М.
Spring Data JDBC: Beyond the Obvious
52:40
SpringDeveloper
Рет қаралды 16 М.
Spring Tips: Spring Boot 3.2
1:21:52
SpringDeveloper
Рет қаралды 72 М.
Spring Tips: Spring AI
22:48
SpringDeveloper
Рет қаралды 56 М.
Domain-Driven Design with Relational Databases Using Spring Data JDBC
1:10:30
Spring Tips: Spring Boot & Apache Kafka
42:59
SpringDeveloper
Рет қаралды 24 М.
Приехала Большая Коробка от Anker! А Внутри...
20:09
РасПаковка ДваПаковка
Рет қаралды 79 М.
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Рет қаралды 1,4 МЛН
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 10 МЛН
Apple. 10 Интересных Фактов
24:26
Dameoz
Рет қаралды 116 М.
Samsung or iPhone
0:19
rishton vines😇
Рет қаралды 7 МЛН