Spring Boot - Spring Data REST and JPA example | Tech Primers

  Рет қаралды 114,246

Tech Primers

Tech Primers

Күн бұрын

This Video covers the Spring Data frameworks which are out there and an hands on implementation with example on Spring Data REST and JPA.
🔗Code on GitHub: github.com/TechPrimers/spring...
📌 Related Playlist
================
🔗Spring Boot Primer - • Spring Boot Primer
🔗Spring Cloud Primer - • Spring Cloud Primer
🔗Spring Microservices Primer - • Spring Microservices P...
🔗Spring JPA Primer - • Spring JPA Primer
🔗Java 8 Streams - • Java 8 Streams
💥Join TechPrimers Slack Community: bit.ly/JoinTechPrimers
💥Telegram: t.me/TechPrimers
💥TechPrimer HindSight (Blog): / techprimers
💥Website: techprimers.com
💥Slack Community: techprimers.slack.com
💥Twitter: / techprimers
💥Facebook: TechPrimers
💥GitHub: github.com/TechPrimers or techprimers.github.io/
🎬Video Editing: iMovie
---------------------------------------------------------------
🔥 Disclaimer/Policy:
The content/views/opinions posted here are solely mine and the code samples created by me are open sourced.
You are free to use the code samples in Github after forking and you can modify it for your own use.
All the videos posted here are copyrighted. You cannot re-distribute videos on this channel in other channels or platforms.
#Spring #SpringBoot #TechPrimers

Пікірлер: 101
@johnwau2485
@johnwau2485 2 жыл бұрын
It is very clear,thank-you for the tutorial bro..
@kemparaj565
@kemparaj565 6 жыл бұрын
Simple, Elegant. A quick tour to SpringJPA. Thanks
@yashjain611
@yashjain611 5 жыл бұрын
Nice and Easy, just as we all want. Thank you Tech Primers for such great explanation.
@harinitatipelli7869
@harinitatipelli7869 5 жыл бұрын
Thank you so much for this tutorial. It helped me to understand the spring jpa in less time
@herbtea1260
@herbtea1260 5 жыл бұрын
I think it is the best lecture. Simple and easy to follow.
@muks
@muks 6 жыл бұрын
Great explanation Dude !! In this video you explained the steps which is very important and in some part also why we have to do it. It's very important to explain why and how rather than just giving coding video. kudos !!!
@TechPrimers
@TechPrimers 6 жыл бұрын
Thanks Mukul. Glad that was helpful
@amitchechare3454
@amitchechare3454 3 жыл бұрын
Just Awesome ......Must say Gr8 peace of work.
@vijayroy3173
@vijayroy3173 5 жыл бұрын
excellent job Ajay
@srikanthch575
@srikanthch575 4 жыл бұрын
Great explanation dude
@samuelvishesh
@samuelvishesh 6 жыл бұрын
6:10 use the keyboard shortcut *Alt + Insert* to Generate code / bring up code assistance 😊
@sourav5562
@sourav5562 5 жыл бұрын
which editor is it?
@gayathrikandaswamy739
@gayathrikandaswamy739 4 жыл бұрын
Thanks Techprimer for this wonderful video. Can you please do a video on how an app with local DB can be deployed in cloud. or if have done it already please reply with the link. Thanks
@biswanathbehera1057
@biswanathbehera1057 6 жыл бұрын
Grt content..sir please upload video on soap webservice and spring Jax ws Integration.
@TechPrimers
@TechPrimers 6 жыл бұрын
sure biswa. will do soon
@biswanathbehera1057
@biswanathbehera1057 6 жыл бұрын
Tech Primers thanks
@biswanathbehera1057
@biswanathbehera1057 6 жыл бұрын
Sir will u please update about Apache cfx.
@20min8s
@20min8s 4 жыл бұрын
Hi Ajay. Can you please do a video on connecting to multiple Ldap servers using spring boot?
@ShinAkuma
@ShinAkuma 4 жыл бұрын
I have been searching for some time now. How do you perform complex queries using JPA ? I want to return a result that contains data from a query using several joins on several tables and other where conditions and returns specific columns from each table as required, how do I do that ?
@Azhagusuryaa2696
@Azhagusuryaa2696 5 жыл бұрын
@ 11:00 , you didn't tell how you start the inbuilt tomcat server.and you didnt explain how the h2 database accept the post call for load
@sureshbabumaddula3005
@sureshbabumaddula3005 5 жыл бұрын
check @ 1:38 added web and h2 d.b from spring starter which adds dependencies in pom.xml
@rorytowler3464
@rorytowler3464 5 жыл бұрын
What application are you using to create and send the JSON to local host? Edit: I did a bit of looking around and think it's Postman
@TechPrimers
@TechPrimers 5 жыл бұрын
Yes Rory. Its postman REST client.
@vikasbhardwaj1502
@vikasbhardwaj1502 5 жыл бұрын
Nyc post can you post this with query dsl also
@jasper5016
@jasper5016 3 жыл бұрын
Can you please explain how can we use multiple joins ( 4 to 5 tables) or complex SQL queries using JPA?
@JeanCarlos-ni4fv
@JeanCarlos-ni4fv 6 жыл бұрын
Do you edited the interface JpaRepository before implement the code because the interface not permit personalize the methods ?
@TechPrimers
@TechPrimers 6 жыл бұрын
nope. can you check if the spring boot version is different
@johnmoe2806
@johnmoe2806 3 жыл бұрын
In the @RestController you did a save then find. There is no need as you can do "return userRepository.save(user);"
@vinodmahato2505
@vinodmahato2505 6 жыл бұрын
sir, my application is not starting, also i checked that the h2 database dependency is present in the pom file, it shows error: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
@yaroslavsoltys4846
@yaroslavsoltys4846 6 жыл бұрын
Why does program failled and write that a bean of the EntityManagerFactory are required?
@KistlakRajapakshaSevenNet
@KistlakRajapakshaSevenNet 6 жыл бұрын
Great Video Bro !! :D Can we use custom query like "SELECT devname,projname FROM tablename WHERE id='userId'" ??
@KistlakRajapakshaSevenNet
@KistlakRajapakshaSevenNet 6 жыл бұрын
Prathemesh Kumar - Did you try source code from the GitHub ?? I think you can get an idea by using the source code..
@TechPrimers
@TechPrimers 6 жыл бұрын
yes u can use custom queries
@somanathbhat5517
@somanathbhat5517 7 жыл бұрын
which IDE are you using?
@TechPrimers
@TechPrimers 7 жыл бұрын
+Somanath Bhat Hi Somanath, I use IntelliJ IDEA from JetBrains. :)
@chinmayabehera513
@chinmayabehera513 3 жыл бұрын
I have created a Springboot,Jpa project and configured 2 databases. Can we update the existing records with Unique constraint? Table doesn't have Primary Key. Here, I am fetching the records from Azure MS SQL Server View and Loading into On Premise Oracle DB Table. In Azure Microsoft SQL Server View, most of columns are having duplicate values. Here, I am fetching the data from Azure DB , then deleting the existing records from Oracle table and inserting the Azure Db data into Oracle DB table. Instead of deleting the existing records from Oracle Db table, can we update the existing records in Oracle DB table ??
@rajeshchilukuri335
@rajeshchilukuri335 5 жыл бұрын
why is that save method for me is not throwing any error and generating id properly, but when i check DB, the data is not present
@madhusudhan9346
@madhusudhan9346 5 жыл бұрын
Hi Your video is very helpful. I have one doubt.After executing "gradle clean build",In mysql - table is becoming empty. Why? what is the issue?
@TechPrimers
@TechPrimers 5 жыл бұрын
you need to check your settings in jpa. if you have instructed jpa to clean up the table after shutdown, it will clean it up
@ayeshabegum24
@ayeshabegum24 5 жыл бұрын
Hi Ajay I am getting null values for findAll(). I have few data in the table. Pls advice
@TechPrimers
@TechPrimers 5 жыл бұрын
looks like your data is not matching your POJO
@RavindraKumar-st3or
@RavindraKumar-st3or 5 жыл бұрын
please tell me the name of the tool which you have used to hit the url and also i want to know where you are posting the data after hitting the url
@TechPrimers
@TechPrimers 5 жыл бұрын
It's Postman client
@sapnakondapallii9135
@sapnakondapallii9135 4 жыл бұрын
Hi good tutorial..... but I am getting error while running app from Eclipse...failed to execute goals spring-boot-maven plugin 1.5.16 .....
@swapnamosali4241
@swapnamosali4241 5 жыл бұрын
can youplease explain how to use websphere JNDI in spring boot data JPA. I have tried many ways its not working.Many people explaining with external tomcat. But I need my application in websphere 9.0.0.7
@miguel1795
@miguel1795 5 жыл бұрын
ajay what tool is that on 0:34 showing spring data connection
@TechPrimers
@TechPrimers 5 жыл бұрын
It's Xmind. Mind mapping tool
@miguel1795
@miguel1795 5 жыл бұрын
tnx bro will try it out
@manashranjan1267
@manashranjan1267 4 жыл бұрын
Invalid derived query! No property name found for type User in JPARepository interface can you explain me sir what to do here
@anandharajanandharaj6231
@anandharajanandharaj6231 3 жыл бұрын
You are searching with invalid name.. you should Search with the value which you you have in your entity class.. For an example in your entity class you have an variable name , age but you are searching by address then JPA doesn't build the query it will throw the error.. you should Search either name or age
@kumarr6195
@kumarr6195 5 жыл бұрын
how to the load Data
@prathemeshkumar4258
@prathemeshkumar4258 6 жыл бұрын
I have raised an Issue on your GitHub repo "github.com/TechPrimers/spring-data-rest-jpa-example". I tried to follow your steps (and also used your repo directly by cloning it), but could never get it to run. Could you please help out?
@ArunabhFunWorld
@ArunabhFunWorld 6 жыл бұрын
Hi Ajay, I need your bit of help as I am getting couple of issues in the above example . I am trying to set up the code that you have shared in git and having following issue. -->When I ran the pom it didn't get the javax.persistence.* dependencies for which Users class started giving compilation error . For which I added below javax.persistence persistence-api 1.0.2 provided ---> After adding the above I am getting following org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil Waiting for your help.
@TechPrimers
@TechPrimers 6 жыл бұрын
Can you check if you are using the same version of spring boot?
@ArunabhFunWorld
@ArunabhFunWorld 6 жыл бұрын
My persistent API jar under m2 was corrupt . So I deleted the hibernate folder under m2 and then it started working. Thanks
@sidramowlana
@sidramowlana 5 жыл бұрын
Is this spring mvc? because if Spring Data Rest is used u wont be needing controllers ryt
@TechPrimers
@TechPrimers 5 жыл бұрын
yes. it is spring mvc
@vk2537
@vk2537 6 жыл бұрын
I m getting this error when i tried using postman "timestamp": "2018-04-05T22:18:08.539+0000", "status": 415, "error": "Unsupported Media Type", "message": "Content type 'text/plain;charset=UTF-8' not supported", "path": "/users/load"
@TechPrimers
@TechPrimers 6 жыл бұрын
you will have to pass the header Content-Type as "application/json"
@amritasingh1105
@amritasingh1105 4 жыл бұрын
What is the IDE you are using ?
@TechPrimers
@TechPrimers 4 жыл бұрын
IntelliJ IDEA
@paulvincent9473
@paulvincent9473 6 жыл бұрын
How to connect with mssql server...??
@TechPrimers
@TechPrimers 6 жыл бұрын
you can add the necessary configs for the spring data connections. do check my video on connecting to mysql database, it will be similar -> kzbin.info/www/bejne/m3rCiZKBlL2ifNU&index=10
@ajitpawar6566
@ajitpawar6566 4 жыл бұрын
But what's code you used for jpa query... You just show basics
@jamuna5181
@jamuna5181 3 жыл бұрын
.save(users); is showing error [create the method save(users)].Could someone help me by saying why this error occurs.
@nandasagar3973
@nandasagar3973 3 жыл бұрын
in ur repo interface have u written @component , and have u extended the interface to jpa Repository. if its properly written check ur controller if u have created an instance of repository and have u autowired it or not .
@madhusudhan9346
@madhusudhan9346 5 жыл бұрын
IntelliJ IDEA is not for free right?what should i use?
@kalyankumar239
@kalyankumar239 5 жыл бұрын
Community version is open source, which is enough for spring-boot
@TechPrimers
@TechPrimers 5 жыл бұрын
It has both version Madhu
@lostalone6816
@lostalone6816 4 жыл бұрын
@@TechPrimers k
@jeftc7122
@jeftc7122 3 жыл бұрын
Hello Ajay , i have coded locally and everything looks fine , it looks like yours , but when i try my endpoint , it just doesnt return anything ...it would be great if you can help please
@TechPrimers
@TechPrimers 3 жыл бұрын
What did do u see in the logs?
@jeftc7122
@jeftc7122 3 жыл бұрын
@@TechPrimers Thank you so much replying back Ajay, appreciate it. I think the problem with me i am using Oracle as DB ..and most of you guys use either MYSQL , H2 etc . ANd based on what have been told from forums videos etc, i have done that for Oracle drivers etc , we use maven and appears that maven doesnt provide oracle dependencies etc ...so at the the moment this is what we are getting in the logs - java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver would be great if you can help on this Ajay , really your help is much much appreciated . Thank you
@sapnakondapallii9135
@sapnakondapallii9135 4 жыл бұрын
Where is the db connection managed
@TechPrimers
@TechPrimers 4 жыл бұрын
By hibernate/hikari datasource
@ILyaCyclone
@ILyaCyclone 5 жыл бұрын
Spring Data REST is a specific Spring Data project and this video has nothing about it. Video title is misleading and made me waste some time here. :/
@thannasip8001
@thannasip8001 3 жыл бұрын
Which tool is this?
@Explore-world-
@Explore-world- 2 жыл бұрын
intelliJ ide
@taufiquealam1614
@taufiquealam1614 4 жыл бұрын
Hello Bro....It's not Spring Data Rest, Please modify title and if you have made videos on Spring Data Rest please share. Thanks for Spring Data JPA.
@jeftc7122
@jeftc7122 3 жыл бұрын
Anybody can help me please ?
@ashgs3460
@ashgs3460 7 жыл бұрын
Hi, Thanks for creating this video. It is helpful. I am getting an error when starting the application, let me explain the major steps. I copied the code from the github repository and running the application under eclipse I get the following: *************************** APPLICATION FAILED TO START *************************** Description: Field userJpaRespository in com.techprimers.controller.UsersController required a bean of type 'com.techprimers.repository.UserJpaRespository' that could not be found. Action: Consider defining a bean of type 'com.techprimers.repository.UserJpaRespository' in your configuration. Do I need to add an implementation of the interface 'com.techprimers.repository.UserJpaRespository'? Warm Regards, ~Ash
@ashgs3460
@ashgs3460 7 жыл бұрын
Managed to fix the issue. The following was needed in SpringBootJpaDemoApplication.java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @ComponentScan("com.techprimers") @EntityScan("com.techprimers.model") @EnableJpaRepositories("com.techprimers.repository") Can someone explain the meaning of @EnableJpaRepositories and @EnityScan? Warm Regards, ~Ash
@TechPrimers
@TechPrimers 7 жыл бұрын
+Ash Gs3 Hi Ash, glad you had it fixed @EnableJpaRepositories - Here we are telling spring boot enable JPA usage. @EntityScan - you provide the package where your entities are placed (models) so that spring can use them for Hibernate
@vamshikrishna8143
@vamshikrishna8143 6 жыл бұрын
for all those, getting white label error, move the main application file SpringBootDemoApplication to the root of the project, not inside any folder. The file is inside the folder if you use spring.io website to download project
@vishnudixit68
@vishnudixit68 6 жыл бұрын
this is not spring data rest example,you have written only namesake it is spring data with JPA not spring data Rest
@NaveenAmruth
@NaveenAmruth 7 жыл бұрын
I couldn't able to run the application. I don't know where I am doing wrong, I double verified all the classes seems to be correct to me Every time I am seeing same error, localhost:8080/user/all Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed May 10 16:28:55 EDT 2017 There was an unexpected error (type=Not Found, status=404). No message available
@TechPrimers
@TechPrimers 7 жыл бұрын
Hi Naveen. Looks like your REST end point is not getting mapped to /user/all. can you share the RestController/Resource file?
@NaveenAmruth
@NaveenAmruth 7 жыл бұрын
Thank you for very quick response. I appreciate it. here is the code what I am using, package controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.ErrorController; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.nsr.model.Users; import com.nsr.repository.UserJpaRepository; @RestController @RequestMapping("/users") public class UsersController implements ErrorController { @Autowired private UserJpaRepository userJpaRepository; @GetMapping(value="/all") public List findAll(){ return userJpaRepository.findAll(); } @GetMapping(value="/{name}") public Users findByName(@PathVariable final String name){ return userJpaRepository.findByName(name); } @PostMapping(value="/load") public Users load(@RequestBody final Users users){ userJpaRepository.save(users); return userJpaRepository.findByName(users.getName()); } private static final String PATH = "/error"; @RequestMapping(value = PATH) public String error() { return "Error handling"; } @Override public String getErrorPath() { return PATH; } }
@NaveenAmruth
@NaveenAmruth 7 жыл бұрын
Hi, Could you please help me on below issue. Thanks!
@TechPrimers
@TechPrimers 7 жыл бұрын
Hi Naveen, What's the significance of adding ErrorController into the same RestController? May be thats the issue here, since you have implemented Error Controller, only "/error" is getting mapped. As you now, Spring is opinionated, you have to do it the way spring wants it. can you split this class and use only the REstController and move ErrorController to a new class.
@boudforsaad5278
@boudforsaad5278 6 жыл бұрын
the right url is localhost:8080/users/all
@huanzhang788
@huanzhang788 4 жыл бұрын
口音真难受
Spring Boot integration with MySQL using Spring JPA | Tech Primers
13:34
REST API Documentation using Swagger2 in Spring Boot | Tech Primers
26:27
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 14 МЛН
$10,000 Every Day You Survive In The Wilderness
26:44
MrBeast
Рет қаралды 138 МЛН
ROCK PAPER SCISSOR! (55 MLN SUBS!) feat @PANDAGIRLOFFICIAL #shorts
00:31
Profiles in Spring Boot | Spring Profiles | Tech Primers
14:13
Tech Primers
Рет қаралды 71 М.
Spring Data JPA Pagination
36:46
Dan Vega
Рет қаралды 17 М.
Spring Batch in Spring Boot | CSV to Database | Tech Primers
41:31
Tech Primers
Рет қаралды 259 М.
What is JPA? | JPA Implementation
26:21
Telusko
Рет қаралды 375 М.
Spring Data JPA: What is it? And Why Should You Use It?
10:37
Thorben Janssen
Рет қаралды 67 М.
APRENDA operar com mais SEGURANÇA
0:12
Wall Street Invest
Рет қаралды 23 МЛН
World’s Longest Vacuum!
0:36
Clean Girl
Рет қаралды 14 МЛН
Adhemz Sigma 55
0:27
Adhemz
Рет қаралды 20 МЛН
路飞一家人都变成丧尸了#海贼王#路飞
0:38
路飞与唐舞桐
Рет қаралды 14 МЛН