Тёмный

SpringBoot : Spring Data JPA - One To Many & Join Query | Example | Java Techie 

Java Techie
Подписаться 180 тыс.
Просмотров 455 тыс.
50% 1

This video explain you How to perform Entity Relation mapping and join operation using Spring Data JPA
#javatechie #springBoot #SpringDataJPA #JoinQuery
GitHub:
github.com/Jav...
Blogs:
/ javatechie
Facebook:
/ 919464521471923
guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
Disclaimer/Policy:
--------------------------------
Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account

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

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 649   
@priyankkabra1
@priyankkabra1 4 года назад
Bro ... awesome ... you just taught what i was searching everywhere on internet. It was all gibberish on everywhere else but you explained it in a very simple way 💥💥💥💥💥💥💥💥💥💥💥
@srinivasulumannem4137
@srinivasulumannem4137 4 года назад
The way u explanation of concept is simple and informative.
@sourabhthorat9550
@sourabhthorat9550 3 года назад
I have tried all permutations and combinations but finally I got correct answer thank you so much sir
@ibrahimdelice9422
@ibrahimdelice9422 3 года назад
Perfect explanations. It is very short but CLEAR. Big like from here!
@saurabhbharti5912
@saurabhbharti5912 3 года назад
Nice explanation , I got it all , thank you very much
@dronatomar5651
@dronatomar5651 Год назад
Thanks for this tutorial , very helpful
@kevin-ru6oe
@kevin-ru6oe 4 года назад
The video was good. But I have an observation. The product entity shouldn't be called product. It should be called Orders. It makes more sense.
@ashuzguitar
@ashuzguitar 3 года назад
Wow. You have good analytical skills.
@rodrickngonyoku5042
@rodrickngonyoku5042 3 года назад
You are a life saver man. Thank you!
@saurabhumadikar2345
@saurabhumadikar2345 4 года назад
Superb Explaination! You are Saviour for me as well as for my fresher colleagues at my office. Thanks for all your efforts in making such great content.🙏
@ak271192
@ak271192 3 года назад
Awesome video, thank u so much 🙏
@mohammedshabbir1347
@mohammedshabbir1347 4 года назад
Hi Basant, Can you please also show how to use native sql query to perform multiple table join and map the resultset to a customized DTO response object using springboot.
@avdeevaelena9977
@avdeevaelena9977 4 года назад
thank you sooooo much!!! God bless you!
@-indeed8285
@-indeed8285 4 года назад
2:45 if you right click on (com.javatechie.jpa) pack and create a new package, it will automatically add com.javatechie.jpa as a prefix. You Don't need to copy paste it. :-)
@Javatechie
@Javatechie 4 года назад
Yes Mohammad , correct am also new to this ide so , np going forward will use more shortcuts
@0DarkPrince0
@0DarkPrince0 4 года назад
lol..just target that parent package and then ctrl+n.. write the class name and edit the package name.
@rajdeepsingh6464
@rajdeepsingh6464 4 года назад
Hi, I see that when you get all customers by calling customerRepository.findall(), you get customer information as well as product information. Question: Since there is one-to-many relation between customer and product entity and in JPA the default fetch type of one-to-many is LAZY, why is it that when you fetch customers, products are fetched eagerly as well? I would appreciate any feedback. Thank you! Awesome video by the way :)
@Javatechie
@Javatechie 4 года назад
Yes Rajdeep you are correct I didn't notice this .thanks I will check and update you
@rajdeepsingh6464
@rajdeepsingh6464 4 года назад
Awesome, thank you :)
@mysocial
@mysocial Год назад
targetEntity = Product.class is unnecessary as products is using generic, aka a typed list (here, of Product). No explanations about CASCADE.ALL -saving Customer will save its Product) or the purpose of the JoinColumn annotation (in OneToOne, create a new column on the owned side to contains the Product PK, in a OnToMany will create the column in the owned side which will reference the Customer PK). So what is this tutorial for ?
@dasunanushka8774
@dasunanushka8774 4 года назад
Superb and excellent.
@manojbhusare6585
@manojbhusare6585 3 года назад
Nice bro
@demigod6190
@demigod6190 3 года назад
You are a gem 💎
@jhonmasco1366
@jhonmasco1366 4 года назад
You are my Hero!
@BhushanRajesh
@BhushanRajesh 4 года назад
In your getInfo Api their is problem in your response. Each customer have multiple products but in your response same customer with different json it will shown. My question is we need to each customer of multiple products will in same json with jpa custom query.
@Javatechie
@Javatechie 4 года назад
How it will show same customer with different json could you please mention the scenario
@saravananpl3857
@saravananpl3857 4 года назад
Awesome!! thanks so much.
@krishnarohit3166
@krishnarohit3166 4 года назад
awesome bro
@Milkyway____
@Milkyway____ 2 года назад
@25:00 can't we use @Builder instead of adding constructor for each new variables?
@Javatechie
@Javatechie 2 года назад
Yes we can
@amanbains5474
@amanbains5474 4 года назад
Bro you are the best !! Can you please refer me your video for the asynchronous micro services call (web client ) and perform sequence of operations (fetch id from first call and use that response field id in second call )) !! I know it is possible in Kotlin , is it possible in Spring Boot !! Any help would be really appreciated !
@Himanshubishnoi-td3nh
@Himanshubishnoi-td3nh 7 месяцев назад
why could not we directly pass customer as parameter in placeorder, is it neccesary to create OrderRequest?
@sunnyshah8321
@sunnyshah8321 4 года назад
Well explained , what About many to many??
@Javatechie
@Javatechie 4 года назад
We can do in same way
@anshumishra8250
@anshumishra8250 4 года назад
Thanx a lot for the content!!! But when I run the same in postman it only saves the data to Customer entity but not to the product, Please explain.
@Javatechie
@Javatechie 4 года назад
Please go through my code and try to find out difference
@SinghRahul-
@SinghRahul- 4 года назад
Thanku so much
@ПожилаяРЭПтилия-ц5б
Hi! Can you please show an example of cascade one to many. For example, a tree view where node contains multiple nodes and each of those nodes contains elements?
@kavinbala5016
@kavinbala5016 Год назад
in the join query , why we need two records for each customer, we need to show customer name and multiple products, i believe mapping is not correct.
@sediksedik7948
@sediksedik7948 2 года назад
Hello I am a beginner working with eclipse java 8 I find this error The method getCustomer() is undefined for the type OrderRequest thank you for your help
@Javatechie
@Javatechie 2 года назад
Configure Lombok in your IDE
@sediksedik7948
@sediksedik7948 2 года назад
@@Javatechie I thank you very much for the quick answer and the solution I wish you a very big success my teacher I am very happy thank you once again
@Javatechie
@Javatechie 2 года назад
@@sediksedik7948 cool buddy 🙂
@manutyagi8019
@manutyagi8019 Год назад
Good morning sir, is it feasible to have two repositories?
@Javatechie
@Javatechie Год назад
Yes why not
@vaibhaVSharma-xh5ru
@vaibhaVSharma-xh5ru 3 года назад
if suppose i have some autogenrated values in entity class, and i want to seperate it from the inputs given by user in another class named request , how to do it
@Javatechie
@Javatechie 3 года назад
Then you need to create parameter constructor and exclude id from constructor
@adamabdullah6789
@adamabdullah6789 3 года назад
can we call the product which have relation to customer ?
@Javatechie
@Javatechie 3 года назад
Yes why not
@m.noumannouman2245
@m.noumannouman2245 4 года назад
hi i face a problem in database when i add new record then the foreign key of customer that is already have any data it not add same foreign key in product table. Every time when i add new data first it make null the above same foreign key then add data and key , i searched but nothing help......
@cswalker21
@cswalker21 4 года назад
I loved it! Thanks, it was easy to follow. My only problem is it seems like there's so many different ways to do the same kinds of things!
@s.a.suleiman
@s.a.suleiman 2 года назад
P P
@diasorynbassar9806
@diasorynbassar9806 4 года назад
Bro, you can't imagine how you helped me!!! Thank you very very very much!!!
@rahulmaharana6506
@rahulmaharana6506 3 года назад
Even helped me .. i was searching for this..
@pratheeban3650
@pratheeban3650 3 года назад
Thanks for your awesome job. Really helpful. Here requesting you to make a video with multiple entity (4 to 5 table) joining jpql query example with all association mapping condition. Everyone explaining the concept with only 2 entity. Thats not enough to understand the concept throughly. Because in real time we need play with many tables at a time.
@ashishmahanta7963
@ashishmahanta7963 Год назад
Please sir make a video how to get data from multiple tables using queries...
@balasubramaniankumaresan8336
@balasubramaniankumaresan8336 3 года назад
The below code I have used, but I am getting null pointer, can you help on this? public class Customer { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int id; private String name; private String email; @OneToMany(targetEntity=Product.class, cascade=CascadeType.ALL) @JoinColumn(name="cut_id", referencedColumnName="id") List products; } public class Product { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int id; private String productName; private int custId; } @Query("select new com.findAdventure.dto.CustomerDto (c.name, p.productName) from Customer c JOIN c.products p ") public List getInformation();
@Javatechie
@Javatechie 3 года назад
Hi Bala , What you are trying and in which api call you are getting null pointer exception If you share me code directly how can i identify the issue
@balasubramaniankumaresan8336
@balasubramaniankumaresan8336 3 года назад
Hi Bro, The same method I have followed, but I am getting Null pointer exception, can you resolve this issue.? @OneToMany(targetEntity=Customer.class, cascade=CascadeType.ALL) @JoinColumn(name="cust_id", referencedColumnName="id") List productDetail; @Query("SELECT new com.findProduct.dto.CustomerDto(d.name, d.mobile, e.productName ) " + "FROM Customer d JOIN d.productDetail e ")
@Javatechie
@Javatechie 3 года назад
Please debug and let me know which exact line giving NPE
@shekhar4176
@shekhar4176 4 года назад
Sir , I think bidirectional mapping is not suitable here , because by this mapping same product can't be bought by more than one person ... What if two person buys the same product , it cannot be done by this mapping. It will definitely give you an error. Please explain it sir !!!!!!
@Javatechie
@Javatechie 4 года назад
Why two persons can't buy same product . Product id should be different right ?
@shekhar4176
@shekhar4176 4 года назад
Because in the product table product ID is primary key and customer ID is foreign If two person buys same product then it will throw an error Because customer ID is number it can occupy only one number And if same product is bought by another customer it can't create another row of same product ID in product table
@chandupatlashashidhar3672
@chandupatlashashidhar3672 2 года назад
I downloaded source code from video description (GiT)..it is showing me error in Postmapping after importing pj .. please check..
@AbhilashMishra15
@AbhilashMishra15 4 года назад
bro... I need some content on "one to many bidirectional " if you can make a video on that it will be awesome. it is easy to understand with your videos as I can't find anything worthful elsewhere. anyways thank you for this video...........
@Javatechie
@Javatechie 4 года назад
Ok bidirectional I will do and share codebase with community Because I don't want to create video with duplicate content 🙏
@vivekmishra5876
@vivekmishra5876 3 года назад
Hi @JavaTechie What if customer Santosh wants to have same Mobile which basant bought { "pid": 201, "productName": "Mobile", "price": 10000, "qty": 1 } In that case it will fail How we will handle that scenario?
@Javatechie
@Javatechie 3 года назад
Why it will fail ? It should add new entry in product table with mapped customer id
@valar-mugulis
@valar-mugulis 4 года назад
I am getting follow exception, please help me out javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [com.example.spring.customer.customerproduct.entity.Product#0]
@Javatechie
@Javatechie 4 года назад
Change the id and try to persist the data
@prakritiagrawal6846
@prakritiagrawal6846 2 года назад
Hello, I am big fan of your videos, I do have a query that, let say if I am using Id.generation type as identity both parent/child in that case how can I set parent id via child while saving parent obejct I am always getting constrainviolation exception I tried all jsonIgnore etc? I am new to hibernate please answer it Thank you !!
@Javatechie
@Javatechie 2 года назад
It seems because of corrupted data .can you please Remove hibernate sequence table from the dB then try it again
@bhaktilatadash7619
@bhaktilatadash7619 3 года назад
In 11.18 You r using request.getCustomer...but u did not create getCustomer methods any where(in Oderrequest Class u diid not use also getter setter annotation) ...i am getting compile time error (when m trying to call request.getCustomer)....please clear my doubt ..how i will overcome this problem..please reply meg
@Javatechie
@Javatechie 3 года назад
I didn't write getter and setter because am using Lombok . Please configure Lombok in your IDE , it will resolve your issue
@anubhab_mukherjee
@anubhab_mukherjee 2 года назад
Just a like and comment is not enough. awesome. keep up the good work.
@Javatechie
@Javatechie 2 года назад
Thanks buddy
@Pain-qu5nr
@Pain-qu5nr Год назад
@@Javatechie do you have one to one tutorial too?
@knowledgeshare1622
@knowledgeshare1622 3 года назад
I want to save an order with multiple orderitems(each order item should have orderId) using oneToMany and Many ToOne bidirectional mapping. But unable to save the orderId in Each orderitem. May I know how can I resolve this problem
@Javatechie
@Javatechie 3 года назад
Can you share your entity structure
@pain966
@pain966 2 года назад
Hey i got error in my code in ordercontroller file " (request.getCustomer());" thay show me to create getCustomer() method in orderRequest class . Plz help me with that🙏
@Javatechie
@Javatechie 2 года назад
Please configure Lombok in your IDE
@sushilbhagat1405
@sushilbhagat1405 11 месяцев назад
if ur native language is HINDI then try to hindi while explaining.. coz ur english putting barriers to understand... we will understand better if u will use hindi as well
@Farm2Code
@Farm2Code 7 месяцев назад
Whatever I'm here understanding him from past 4 years he is good at what he is saying. English
@999inf
@999inf 3 года назад
How can I reference a collection from an entity in this instance you joined a product from the customer because it has one to one mapping, what if I have a collection of products in the Customer class where @OnetoMany i tried the same method and JPA throws an error saying it can't reference a collection.
@Javatechie
@Javatechie 3 года назад
Mohammad this is one to many example only please cross verify once
@SlBoss14
@SlBoss14 Год назад
Is it possible to write query in property or yaml file and fetch query from it.. like @Query(${query})? Please reply
@Javatechie
@Javatechie Год назад
Never tried that
@Fozzix66
@Fozzix66 2 года назад
Thank you so much, It helps me a lot
@pranaypaul6361
@pranaypaul6361 3 месяца назад
Excellent basics giving continuous value to Spring journey....one question just is it still the best practice in industry today? I found it valuable but my query is if I need to know further to match current standard on such join query mappings? Thanks!!
@Javatechie
@Javatechie 3 месяца назад
If it's microservice architecture then I would say this is such a bad practice
@pranaypaul6361
@pranaypaul6361 3 месяца назад
@@Javatechie ok....any recommendation then?
@lakshmiprasannat4147
@lakshmiprasannat4147 Год назад
Hi all, please help me i am getting InvalidDataAccessApiUsageException: Entity must not be null
@Javatechie
@Javatechie Год назад
Check the annotation part
3 года назад
I am surprised you import data access layer instance directly in to controller layer. This is not safe and is not a typical way to do things. Why don't you use service layer?
@Javatechie
@Javatechie 3 года назад
Hi buddy you are correct . Always I mentioned same that use service layer even I used few of my video also .but this is a demo Vedio and to save your time usually I follow this approach
@storyteller_x
@storyteller_x 3 года назад
Copied and pasted the code But im facing the error while posting the data as "A diff object with same identifier value was alredy associated with the session"
@Javatechie
@Javatechie 3 года назад
Please restart your application
@anusathiya8887
@anusathiya8887 3 года назад
What is dto means? why do you name a package dto? But thank you for your time and explaining the concept to the core...
@Javatechie
@Javatechie 3 года назад
dto - data transfer object
@arkadey3241
@arkadey3241 3 года назад
Hi, In this application if we want to fetch the products, along with the product can we get the customer details too? When I tried, it was getting into an infinite loop.
@Javatechie
@Javatechie 3 года назад
No you need to write join query for all information you are expecting
@NelsonMoralesChile
@NelsonMoralesChile Год назад
friend, where did you get or create the getCustomer method??? my Ide sts says it is undefined. can you guide me please
@Javatechie
@Javatechie Год назад
Have you configured Lombok in your ide? If not please configure it
@avonzo
@avonzo 2 года назад
Why do you have to do @ToString when you already have @Data? Doesn't the @Data cover for @ToString?
@Javatechie
@Javatechie 2 года назад
Yes @ToString you can ignore it's already there in @Datq
@jindalsumit19915815
@jindalsumit19915815 4 года назад
Very well explained. All seems so clear after watching this. Keep it up!
@EventuSocialClub
@EventuSocialClub 3 года назад
Very nice explanation! (Please, do something with your English :-D )
@bhagatreddy9778
@bhagatreddy9778 3 года назад
hi Bro, below is my courseEntity public class Course { @Id private int course_id; private String course_name; @OneToMany(targetEntity=Topic.class,cascade = CascadeType.ALL) @JoinColumn(name = "tid_fk", referencedColumnName = "course_id") private List topics; private int rating; private int prize; } when i make a post request with below data its giving me java.lang.IllegalArgumentException: exception { "course_id": 1, "course_name": "spring", "topics": [ { "topic_id": 1, "name": "java", "importance": "high", "description": "Core Java" }, { "topic_id": 2, "name": "mysql", "importance": "high", "description": "mysql basics" } ], "rating": 8, "prize": 3000 } BUT WHEN I CHANGE "topics" to "topic" in private List topics; its working fine. ofcourse in request i will be send "topic" instead of "topics". basically my question was why doesn't that work if i give name as "topics" instead of "topic" MY TOPIC ENTITY: @Entity public class Topic { @Id private int topic_id; private String name; private String importance; private String description; }
@Javatechie
@Javatechie 3 года назад
It should work it doesn't relay on variable name if you named it as topics then make sure to send topics as a key in json
@bhagatreddy9778
@bhagatreddy9778 3 года назад
yes i'm sending the same name in the request also, but not sure why its not working. and also one thing i'm not getting java.lang.IllegalArgumentException. but topics entity data is not storing my request is { "course":{ "course_id": 1, "course_name": "spring", "topic":[ { "topic_id": 1, "name": "java", "importance": "high", "description": "Core Java" }, { "topic_id": 2, "name": "mysql", "importance": "high", "description": "mysql basics" } ], "rating": 8, "prize": 3000 } } but i'm getting { "course_id": 1, "course_name": "spring", "topics": null, "rating": 8, "prize": 3000 } in response even i don't see any data in topic table
@smritirani5527
@smritirani5527 Год назад
I have an error and entity must not be null can anyone help me real quick
@enockjr5048
@enockjr5048 11 месяцев назад
Me too
@Javatechie
@Javatechie 11 месяцев назад
Check the annotations defined in entity class and it's import statement
@kaushikkumar5415
@kaushikkumar5415 3 года назад
first of all thanks for the video, How can we add more Product later on to any specific Customer, Please help me
@Javatechie
@Javatechie 3 года назад
Since this is one to many we can use same payload to add N number of products specific to a customer
@shankarkrishnamoorthy6037
@shankarkrishnamoorthy6037 3 года назад
Is is possible to add , update products for an existing customer in this video . How to go about this thanks brother
@Javatechie
@Javatechie 3 года назад
Yes update is not a big deal , Just get the existing object by id then copy input object data to existing one and save it .
@somyakumari3238
@somyakumari3238 Год назад
Explained in very understandable way.. really thank you sir .. I have a question ,do you provide high level live project courses..?? Please let me know... Thank you
@Javatechie
@Javatechie Год назад
Not yet started buddy
@somyakumari3238
@somyakumari3238 Год назад
@@Javatechie please start soon sir.. i would like to join
@amarjargalamraa3330
@amarjargalamraa3330 3 года назад
how to input value in mysql example @Query( select book.author, bookshop.ShopName , book.bookName from book, bookshop where book.bookId = "this value") pls help me :D
@Javatechie
@Javatechie 3 года назад
Please check my spring data jpa tutorial
@amarjargalamraa3330
@amarjargalamraa3330 3 года назад
@@Javatechie okey Ty :D
@danielniels22
@danielniels22 2 года назад
is it the same whether we put the Query either in CustomerRepository or ProductRepository? Is it literally the same?
@Javatechie
@Javatechie 2 года назад
Yes but which entity is your parent you need to always add query on that repo
@faizoddinquazi2298
@faizoddinquazi2298 2 года назад
Hi Sir, no records are getting inserted into the db. I imported the git repo directly as well!!
@Javatechie
@Javatechie 2 года назад
Configure Lombok in your IDE
@AnilKumar-dt3sq
@AnilKumar-dt3sq Год назад
Hello Basant brother, I follow all your tutorials and the way you explain the topics and demonstrate with examples is incomparable. However, with this tutorial, I have a query. I tried this jpa query but getting the following error : IllegalArgumentException : Query annotations may only use interfaces to map results to non-entity types. Could you please help ?
@Javatechie
@Javatechie Год назад
Thank you so much buddy for your word . Could you please share the @Query annotations where you have write ✍️
@AnilKumar-dt3sq
@AnilKumar-dt3sq Год назад
@@Javatechie I have written it in an interface extending CrudRepository e.g : interface Xrepository extends CrudRepository{ @Query(" ") getInfo(){} } do you need the query as well? its actually a join of 3 entities, returning 3 attributes from 3 tables which I am mapping to a DTO.
@Javatechie
@Javatechie Год назад
What is the query, if you don't mind can you share your GitHub link to javatechie4u@gmail.com
@itsnarahari
@itsnarahari 3 года назад
Bro in spring boot for auto ddl created date is not getting default timestamp even if we add in columndefinition
@Javatechie
@Javatechie 3 года назад
Could you please share your entity structure
@sravankumar9751
@sravankumar9751 2 года назад
Thank you for clear explanation. I do have a question. In Customer repository, we are trying to get customised response, which is not in the structure of Customer pojo. I am getting error for that, but it works for you. Can you explain me how will it work.
@Javatechie
@Javatechie 2 года назад
What error you are getting
@sravankumar9751
@sravankumar9751 2 года назад
@@Javatechie Error creating bean with name 'orderController': Unsatisfied dependency expressed through field 'customerRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository' defined in com.sravan.jpa.Repository.CustomerRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.sravan.jpa.Repository.CustomerRepository.getOrderDetails()! Reason: Validation failed for query for method public abstract java.util.List
@raghuvaranaj1863
@raghuvaranaj1863 3 года назад
Hi, I'm using the same code but the DB is postgres but its showing "org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist" error. Can you help me.
@Javatechie
@Javatechie 3 года назад
@id annotation not working ? Try to insert id manually and let me know
@raghuvaranaj1863
@raghuvaranaj1863 3 года назад
Sorry @@Javatechie something wrong/extra line in the application.properties file i copied from another repo. I changed your's property file to postgres its woking now
@Javatechie
@Javatechie 3 года назад
Cool 😎
@sagarsaud156
@sagarsaud156 4 года назад
CAn we make DTO class with Native Query too? Also Can we make Join Query with entities without having relationship?
@Javatechie
@Javatechie 4 года назад
If there is no relationship between entity then why we need join first of all ? Yes as per your join query expected return value you need to create corresponding dto . It doesn't matter whether you are using native query or hql or jpql
@sagarsaud156
@sagarsaud156 4 года назад
@@Javatechie I tried with this but didn't work. @Query(value="SELECT new com.doc.importexport.dto.FirmHelper(f.firm_Id, f.firm_Name, f.firm_Registration_Number, f.proprietor_Name, f.firm_Address, f.proprietor_Contact, f.bank_Name, f.tt_Dap_Number, f.tt_Date, f.tt_Dap_Amount, f.application_Date,f.invoice_No, f.invoice_Date, f.bl_No, f.bl_Date, f.shipped_On_Date, f.revenue_Status, f.verification_Level, f.sender_Name, f.request_Date_Nepali, f.request_Send_By, f.assistant_Verification,f.assistant_Verification_Date, f.officer_Verification, f.officer_Verification_Date, f.director_Verification, f.director_Verification_Date, c.currency_Type, co.custom_Office_Name, pm.payment_Type, sp.sea_Port_Name, f.firm_Document, f.revenue_Amount, f.revenue_Voucher, f.request_Sender_Id) FROM Firm f, Sea_Port sp, Currency c, Custom_Office co, Payment_Method pm WHERE f.payment_Method_Id=pm.payment_Method_Id AND f.seaport_Id=sp.seaport_Id AND f.custom_Office_Id=co.custom_Office_Id AND f.currency_Id=c.currency_Id AND f.firm_Id=?1", nativeQuery = true) public FirmHelper getFirmDetailsByFirmId(int firmId);
@sagarsaxena4569
@sagarsaxena4569 3 года назад
hi, i am getting an error at 11:03 with getCustomer. The error says getCustomer cannot be resolved or is not a feild. Please give me the fix. Thank you
@Javatechie
@Javatechie 3 года назад
Please configure Lombok in your IDE otherwise manually add getter and setter method
@sagarsaxena4569
@sagarsaxena4569 3 года назад
@@Javatechie alright, thanks for the response.
@darshanraut554
@darshanraut554 2 года назад
Add targetentity but why ? Add cascade but why ? Add joinColumn but why ? Why cant you explain man ? No point just using them if we dont know whats their use. Such a waste of time...
@Javatechie
@Javatechie 2 года назад
Hey Darshan it's just demo for spring jpa association mapping not hibernate tutorial. Do let me know if you want me to cover this as a separate session
@kingsroyal1600
@kingsroyal1600 2 года назад
@@Javatechie Yes Please do one video on all enums which are present in Hibernate, JPA, and Spring frameworks, spring boot . I searched for these enum types nobody did videos on this. If possible kindly do a few videos on all enum types
@kingsroyal1600
@kingsroyal1600 2 года назад
@Darshan Raut very nice question. beginners are expecting this type of question. We should know how to use them, where to use them, and scenarios they are using ...etc
@ShinAkuma
@ShinAkuma 4 года назад
How will I create complex SQL queries with JPA, this feels too limiting. Like with normal JDBC you could write the SQL as a string directly so we were able to use advanced SQL features like analytical functions, subqueries, aggregate functions, grouping etc. How will I implement all those in JPA ? Even creating a normal Inner join is a tedious task. What if I want to join multiple columns even if they are not key columns ? I dont want to create a physical foreign key column in either table but I want to get the result using a join. This is confusing.
@AlhambraDream
@AlhambraDream Год назад
I think you scan write native SQL with @query tag
@ShinAkuma
@ShinAkuma Год назад
@@AlhambraDream Yea, but that's native and database dependent. Anyways I learnt how to do joinings and other complex operations using JPA queries now.
@AlhambraDream
@AlhambraDream Год назад
@@ShinAkuma how?
@shivarena8254
@shivarena8254 3 года назад
we no need to write that dto class to map the specified columns through join query
@Javatechie
@Javatechie 3 года назад
Can you please share any other approach
@khushalijiyani6397
@khushalijiyani6397 3 года назад
Sir, it is possible to have the different customer buying same product . In that case the customer id is getting overriden then it that case what should be done to get both the customer ids.
@Javatechie
@Javatechie 3 года назад
It won't override instead it should add a new entry
@khushalijiyani6397
@khushalijiyani6397 3 года назад
@@Javatechie sir I have implemented it using course and students. In that multiple course can have same student. As we need to mention the primary key in spring boot while creating table so it won't allow repetation of the student. The foreign key(course_id) is getting overriden in the student table.
@sleepyhead1880
@sleepyhead1880 3 года назад
Man you are such a life saver
@palakodeticharithardha3499
@palakodeticharithardha3499 3 года назад
Good work... But please check Customer and Product will have many to many relationship... It's not one to many... Use customer - Order as example .. that is pure one to many
@singlekasi
@singlekasi 5 месяцев назад
Good beginner tutorial . Would be good if bi directional one to many with tests for CRUD are shown . The sliced test approach using @DataJpaTest makes it easier to test the JPA repository part of the code in isolation. However , I think Java Techie covers this on his test containers video . Keep up the good work
@abhishekchauhan4230
@abhishekchauhan4230 2 года назад
Thanks a lot i mean from my heart I was looking for this for a long time and now I got it :)
@abhisheksharma8589
@abhisheksharma8589 4 года назад
This program throwing IllegalArgumentException ...
@Javatechie
@Javatechie 4 года назад
Please do cross verify with my code which I shared in GitHub link mentioned in video description
@RathourShubham
@RathourShubham 2 года назад
why @ToString, @Data creates ToString automatically
@Javatechie
@Javatechie 2 года назад
Yes agreed!
@maheshbabunadigoti7050
@maheshbabunadigoti7050 3 года назад
detached entity passed to persist: com.example.demo.model.Products; nested exception is org.hibernate.PersistentObjectException: detached entity passed to persist: com.example.demo.model.Products" I am getting this error. I tried same like u but can u tell me the error solution
@anshikaupadhyay1958
@anshikaupadhyay1958 2 года назад
hello sir at 11:58 when i run the program, it gives error saying null entity at the getCustomer() method, please help
@Javatechie
@Javatechie 2 года назад
Please configure Lombok in your IDE
@anshikaupadhyay1958
@anshikaupadhyay1958 2 года назад
@@Javatechie okay thankyou
@saswatisamal571
@saswatisamal571 3 года назад
Thank You so much Basant.Can you help to understand how SpringData JPA works internally and intelligently creates query for database operation
@emoboy2351
@emoboy2351 4 года назад
Very helpful, u're a saviour, thnx a lot
@faizoddinquazi2298
@faizoddinquazi2298 2 года назад
Hi Sir, Thanks for the session. It has cleared most of the doubts. I am unable to execute ant create statements from hibernate while running the program and getting below error. Please help to figure it out. Error executing DDL "create table customer (id integer not null, email varchar(255), gender varchar(255), name varchar(255), primary key (id)) type=MyISAM" via JDBC Statement Error executing DDL "create table hibernate_sequence (next_val bigint) type=MyISAM" via JDBC Statement
@faizoddinquazi2298
@faizoddinquazi2298 2 года назад
After correcting the MySQL dialect property it got fixed org.hibernate.dialect.MySQL5Dialect
@jesuseduardovillamizarchac4298
@jesuseduardovillamizarchac4298 3 года назад
Hi, how can I get the source code of this example, thanks
@Javatechie
@Javatechie 3 года назад
Github link mentioned in video description
@marypaul9627
@marypaul9627 Год назад
Hi Java Techie,i get confused with entity and dto..why exactly do we need dto?
@Javatechie
@Javatechie Год назад
Dto is just to capture your request and response attribute but entity is the real value which will persist to your database
@marypaul9627
@marypaul9627 Год назад
@@Javatechie Thanks and why is the advantage of capturing the request and response in dto way instead of the entity itself?
@chinmayabehera513
@chinmayabehera513 4 года назад
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 ??
@Javatechie
@Javatechie 4 года назад
Yes we can update but how you will find out duplicate record ? You need to compare somewhere right ?
@vsev010d
@vsev010d 4 года назад
Why don't you show what sql query does hibernate generate?
@Javatechie
@Javatechie 4 года назад
You can do that Simple just add show.sql=true in application.properties file .
@rayhanarwindra9944
@rayhanarwindra9944 4 года назад
Hello, I'm getting error when saving: Caused by: org.h2.jdbc.JdbcSQLDataException: Value too long for column "LIST_OF_APPOINTMENT VARBINARY(255)": "X'aced0005737200136a6176612e7574696c2e41727261794c6973747881d21d99c7619d03000149000473697a6578700000000177040000000173720021636f... (476)"; SQL statement: Can someone help? Thanks
@Javatechie
@Javatechie 4 года назад
Can you share your entity class?
@rayhanarwindra9944
@rayhanarwindra9944 4 года назад
@@Javatechie @Entity @Table(name = "Student") public class Student extends User { @OneToMany(targetEntity = Appointment.class ,cascade={CascadeType.MERGE,CascadeType.REFRESH}) @JoinColumn(name = "appointment_id",referencedColumnName = "id") private List listOfAppointment; .... } @Entity public class Appointment { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO) private long appointmentID; .... }
@Javatechie
@Javatechie 4 года назад
Why you extends from user class ?
@rayhanarwindra9944
@rayhanarwindra9944 4 года назад
@@Javatechie because there are other types of users, i.e students and lecture assistants. Is that the causd of the problem?
@Javatechie
@Javatechie 4 года назад
Yes , then go for inheritance mapping
Далее
КОТЯТА В ОПАСНОСТИ?#cat
00:36
Просмотров 1,1 млн
Шоколадная девочка
00:23
Просмотров 84 тыс.
pumpkins #shorts
00:39
Просмотров 12 млн
Spring Data JPA from 0-100 in 60 minutes
1:02:31
Просмотров 81 тыс.
#12 Hibernate Tutorial | Mapping Relations Theory
13:14
Kubernetes 101 workshop - complete hands-on
3:56:03
Просмотров 1,6 млн
Java API development
3:02:48
Просмотров 7 тыс.
КОТЯТА В ОПАСНОСТИ?#cat
00:36
Просмотров 1,1 млн