Thank you so much sir for your hard efforts for us to make us with easy learn. Awesome and very helpful videos and you also explain the concept very well. Thanks , i took reference of your this code and videos to implement my task, now i need to connect my API with 3 database as @primary will help for between two database .. as for three database i am getting , how i can mange it with qualifier or any other ways for the same. Thanks for your hard efforts as you bring knowledgeable videos. Thanks.
Hi, Java Techi, Thank you for your video, I have a doubt I configured just like you with customer and order in two different DB and they are in one to many relation so when I set scan packages to com.example in config I'am able to create table but all tables are getting created in both DB how do I resolve that and make to create only one table in each DB
Hi sir good explanation, I am having a doubt I need to connect different schemas like user model has separate user schema and book model has separate book schema but both are in sql database , may i use this same configuration for this task and also should i create a separate separate packages for both "pls reply "
@@Javatechie Is there any way we can pass dynamic schema name rather than hardcoding in application.properties? let's say adding new schema for any new client enrolled to system. Thanks in advance!
i didn't understand onepoint; there are two entityManagerFactory in 2 db config class. What if we have so many entity classes and repo classes in the project? do we need to create config file for every single model class that we have ?
@@Javatechie You have used persistent Unit name as "User' . So my question was what if there are 10 entitites. ? Should should write configuration for all 10 entities as persistant Unit?
We are manually creating datasource specific to database then we are adding required configuration stuff Once our datasource created we are mapping it to entity manager .
Awesome :) Exactly what I am looking for :) Thanks a lot With the reference of this I am able to integrate Spring boot with MySQL and Neo4j repositories at the same time.
Thanks for the step by step execution dear Friend! Actually, I have downloaded a copy but it was not working for me. when I watched this video I corrected a few things in the code and it was working fantastically.
However, I would like to know how to send data as a JSON to the endpoint? because what I could see is that passing the values to Model classes in a program itself. I want to know how to do it dynamically at run time with postman?
@@vijayakumarkrishnan9269 this is backend code that's why I tried with postman but if you want data in real time scenario then it should be pass through client (angular, Ajax)
@@Javatechie Yes, exactly, I have a client app which submits the data from a web form to backend endpoint via Ajax post. but would like to know how to process Ajax data in backend repository code or in the controller.
Nice Video could you please clarify the below points 1. (23:24) in persistanceUnit("Book") we configure for one table entity, what if the db have some 10 tables how to configure all of them 2. And you created Repository by extending Jparepository what if we want to interact with 10 tables in that Db. 3. is there any way to configure EntityManager per datasource so that we can interact with all tables in that datasource? Please explain these points.
Very nice explanation. Keep it up. Can't we keep both user and book repository interfaces in a single package instead of keeping in 2 different packages??
Hi, I Need your advice here. I’m building a web application which allows users to choose database (HK,UK,US) from the UI. Based on his selection of databases, I need to connect to respective DB instance in the spring boot + Jpa. Please share your thoughts!
We can do one thing Based on UI input we will enable profile for region rather than environment Let's se I chooses UK then from application we will setActiveprofile to UK so that corresponding datasource properties will be loaded . Do let me know if you have any issue. Very interesting concept
Hi, Can we join two tables from different databses? Say employee is in oracle DB and Department in mysql DB. I dont want to join inside service but want to join in repo using jpql.
Nice video basanth.. How @configurationproperties() working here.. because in properties file the prefix is (spring. User........) but in your config class you mentioned pring.user... how the data source were created in your application. Check at time about 12:19 .. nice video..
@@nageswararaopalchuri3003 you can ignore it ,I just used it to disable all the database related auto configuration as I configured manually using java base config approach
Hi, really nice video. Is this also the way to achieve dynamic data source routing? If in the payload we getting which database we require to query/update. Will this be an optimum way to do it?
Hi @Java Techie Can we Datasource-1 for Multiple repositories? Example: I am having two Data Sources DS-1, DS-2 DS-1 contains Books, NewsPaper, Notes, Ref-Materials, etc tables, Whereas DS-2 contains transactions of users. It's Possible to connect DS-1 with Multiple Repo?
Very nice Explanation.. Requesting you to pl. make a similar 30 minute video including code example for distributed transaction management using Spring Boot microservice. Thanks!
Thanks for the video. Can you please make a video showing Springboot Application which will be deployed to Weblogic Server and connect to a JNDI datasource which is already created in weblogic server. Thanks in advance.
I have 2 schemas, and both are identical (they are just replicas), do I still need to maintain 2 different models and repositories? Or can the basePackages be the same?
@@Javatechie what is that persistent()?. There you mentioned entity name. But what about if we have multiple entities. How do I mention entities to that persistent.
@@otshudiakoy2012 am not sure but yes I did something like below Take DB dump of your remote DB then import it in your local or just point your local DB to remote host . So that both info can be on sync
I have one doubt? I have two schemas work -> customer_table work2 -> customer_table how can I call dynamically for different schemas? I have one POJO class and one repository, how to change the table name dynamically.
Nice video ... Can we able to join two entities from different datasources and fetching selected columns from both the entities ? is it possible ? Eg : joining User with Book with foreign key and fetching username,bookname after joining.
Thanks for this wonderful video..it's so helpful.. Awesome way of explaining.. thanks for your efforts for us learners... Sir I have one question... without @Entity class we can connect to data base..as I need to fire queries..having different table...how I can do that.. please suggest.. I don't want to create table in db ..but want to retrieve data from different table...in case..I don't need that that Entity class created..I made dto..to fetch the data....but..how I can do..can you please suggest
Hi, I have downloaded the code from git and tried to execute. Its creating both the tables in one schema only. Any idea why so? I also have to add few properties in POM.xml to make it work
Why separate config for each entity ... can't it be done on single config class .. as in real time we will be having multiple entities so i don't think it's good practise to create separate config for each entity. Any suggestion on that
Yes it's on table level. But what If I have to achieve a common/ global transaction on two diff tables... Example: a distributed Trx mgmt, if there are two tables(say db1.table1 and db2.table2).. but using single Trx. Like, if amount debited from db1.SBI table is successful. But credit in db2.hdfc table is failed. Then it should rollback. And SBI refund should be there. so if you can demo using Hibernate Jpa and spring boot. It would be great.
we have created two data sources each data source has one table, what if we have more tables in each data source, how we create entities and how we bind to particular data source?
It's really helpful . I created a sample project. While I am trying to run the app, I am getting below mentioned exception. Please help Parameter 0 of method entityManagerFactory in com.stand.work.config.CompanyDBConfig required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.
Hi ... Thank you .. I have went through all your videos related to the H2 and multiple datasources, as I'm building my spring boot objects based on that. But in my spring-boot application I'm using multiple datasource , one is Oracle and other one is H2 database. My application is connecting to Oracle Database, but h2-console is not opening. do you suggest any solution for it. Here is my application.properties file looks like. #oracle spring.oracle.datasource.jdbcurl= spring.oracle.datasource.username= spring.oracle.datasource.password= spring.oracle.datasource.driver-class-name= #H2 spring.h2im.console.enabled=true spring.h2im.console.path= /h2-console spring.h2im.datasource.platform= h2 spring.h2im.datasource.jdbcurl= jdbc:h2:./test spring.h2im.datasource.username= sa spring.h2im.datasource.password= spring.h2im.datasource.driver-class-name=org.h2.Driver
U give input like user and book to the value of the persistence unit So is it means name of the model class If it is yes how can I give all model for that..
Dude please watch from begin I mentioned there as I don't have multiple databases install in my machine am giving example using two different entity Let's say I have Oracle and MySQL Oracle db I can configure N number of entity similarly for Oracle I can configure N number of entity Because in one database we xan have multiple entity If you have multiple DB in your machine then please try configure it and see I Just configure 2 schema to show demo how to configure in case data source .
@@Javatechie @Akshat Pandey, could you please send share your code how u configured mysql and mongo in single application. I'm facing problem with mysql+mongodb databases combination
Getting error: Parameter 0 of method studentEntityManagerFactory in com.school.config.StudentsDataSourceConfig required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found. Action: Consider defining a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' in your configuration.
You want to update record ? If any field changed right ? So first you need to get existing object from dB then set the new value to object next save it