Java Mock Interview - Java interview questions and answers for experienced | Top Spring Boot QNA

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it's not a game [Music] hello and welcome back to another live mock and in this mock i'll be talking with lavanya and she is an experienced java developer and hopefully we're going to have great fun you know um i'll be i'll be special especially having great fun interrupting uh lavanya and hopefully that's gonna be um you know finding it helpful and obviously i'll be covering a wide range of questions in java springs springboard hybrid gpa and many more okay so let's start the interview and i hope you guys are excited and i am too all right so let's get started [Music] all right so let's start with the interview i have lavanya with me and uh welcome lavinia welcome back and for the first time we'll not be having a lesson we'll be having a mock all right so yeah so i just want okay before we get started with anything i want you to introduce yourself a little bit like about your experience the things that you are learning and um obviously you know basically tell a little bit about your past experience and everything yeah yeah like i have around six and a half years of experience in service side development i have knowledge on java programming language and spring modules like spring course spring mvc spring boot uh spring jps and hibernate web services so yeah and you skipped a lot of different things i want to add like yaml time leave jpa yeah so that's okay so basically um the thing is like you are like you know having a complete hands-on experience with java spring hibernate this is your main profile lebanon right what we have discussed previously and obviously i'll be start asking you questions on this right now so yeah so in which module you want me to get started all right um why not from java okay this time i'll do the reverse i'll not i'll start asking from spring okay we'll start from a very easy question so they have said right uh so we'll start asking easy questions first then we'll go in a little little in depth later on so yeah and one thing guys i will not be asking anything to lavanya which i have already asked to other candidates if i have taken more can post it on vimeo in your paid playlist or in your free playlist on the youtube so i'll not be asking those questions to love there's going to be uh some new questions which we have not covered earlier so yeah so yeah so i just want to get started with marker interface so tell me what do you mean by a marker interface in java and what do you think we need it in our real time java programming okay so marker interface is an interface which actually doesn't have any methods or the constants defined in it it actually gives an additional information or a kind of metadata about a class which has implemented this marker interface there are many built-in marker interface like serializable and cloneable so cl plane so in a class that a clonable interface we can override a method called clone in the object method in the object class so that means we can create a copy for example if we have a student class and we have implemented this cloneable interface we would be able to override this clone method so in that with the help of this clone method we can easily create a object similar objects which we have created for a student class so basically it will create only a shallow copy not a deep one it will try to create only a student object all the user defined inside independent objects are not created it will be pointing to the old object only you just said that clonable is a marker interface and we don't have any methods defined or any constant you find in that particular yeah so you said couple of things maybe you said about clonable and maybe we have serializable interface right yes you if you're learning spring data jpa you know the root interface repository like jp repository crowd repository and this extends to repository that is also a micro interface no methods inside that i just have one question here lavender why do we need micro interface if there is no methods inside it there is no constants inside it what do you think is needed actually it adds a special features like we can make use of the functionality like clone if we uh see the cloneable interface uh we can you make use of this clone method but when we don't have this uh method the cloneable interface implemented to a class we might not be able to create logic likewise this can be even achieved with the help of annotation these days but uh but even the marker interfacing is a replacement for this but yeah a micro interface is like you know it has its own functionality like uh i can use a led tv as my monitor but it cannot do the work of an actual monitor right yes yes yes yes yes so the thing is like you know we need to do a run time check right if this class or this object i am getting and this object is air you know instance of that you know it is implementing that particular interface of that interface then only i'll need to do some operations for example imagine you've got some methods someone tell you to create some methods and that that method need to do something but we need to only perform some operation when it is a instance of that interface so that jvm can do using the it can do an instance of check and can see whether we're implementing that one [Music] and guys who are watching this video i will not be going in depth of that i'll not be asking um lavinia some more questions but maybe your interviewer also can counter you over here like um if lavinia if there is um like you know if we have a marker interface right and why don't you think the same functionality can be done by a normal interface also we can do the same thing in the normal interface right so do you know the answer for this like uh yes we can do it but even for example if um we can we can achieve the same thing but there are no way yep that problem you guys need to find out tell me in the comment section okay and me and lauren i will be discussing in the end of the interview right not right now okay um all right comfortable right now you are becoming comfortable yes the next question yeah i have written a few questions for you um okay let me just ask you some easy questions because i've written down some of the easy questions to make you comfortable first because i want you to speak a lot of different things with me okay tell me five different exceptions in spring okay that you usually encounter in your day to day project i'm putting myself on mute go ahead okay so the main exception class of string is spring beam creation exception this basically occurs when uh for instance if i take another exception like no such beam definition exception so this exception occurs when we don't have any spring beam which we have auto wired in another class so spring tries to find the definition of the class and try to inject in that auto wire or wire dependency so in this case if the bean is not available in the container it will throw a no such bean definition exception this one will occur the next one what i see is non-unique bean definition exception for example if we have an interface my interface and we have two implementation class for this interface and we have a class a and that class we it has an auto wired dependency of this inter interface so both the classes is annotated with the both the class which is implementing this interface is annotated with at the reach service or at the rate component so two beings will be created of type my interface so the spring get confused which one to auto wire here so in order to overcome this what we can do is there are two ways one is to use at the rate qualifier telling the reference name to it or you can make one of the service to act as primary always so this is another exception that i see the next exception is beam in creation exception number three number three so this ex this exception will come when there are circular dependencies between any two classes for example if we have employee and department employee has a dependency of department and department has a dependency of employee and both are created using constructure injection so in this case employee will be in search of repair department and department will be in search of employee so there are ways we should not you make circular dependencies in our project so we can have certain principles to follow and there are a few methods to over overcome this kind of circular dependencies and next one the fourth one i see is being instantiation exception for example if we have a class which is abstract and if we try to uh annotate it with authorized service or if we try to define it by ourself using other 8 bean in the configuration class at that time during the application startup it tells bean instantiation exception [Music] this the fifth one i would like to tell it from boot uh application context exception so this exception will come then we must at the rate enable auto configuration in the board because the framework will try to create uh the server context container servlet container object but without this annotation it will not be able to uh uh create one so it will throw this exception telling us whether we have to create a object or add the operating configuration good job such a detailed explanation thank you very much i don't think i have to add any slides with this explanation isn't it so anyhow thank you very much for the detailed explanation lavender but i i'll try to put some of the slides so that if you guys want to utilize it i'll tell everyone to give me the code and i'll be pasting it over here okay all right cool [Music] all right next easy question okay i'll i'll give you a lollipop kind of question uh tell me five spring annotations okay okay i'm telling you five spring annotations that you have used in your spring conditional that is the star mark here okay you don't need to tell me any of the stereotype annotations excluding the stereotype annotation tell me five spring annotations that you have used oh stereotype in the sense uh the the basic annotations you you i don't want to tell that yeah that's why i i've added this watch stereotype now you need to tell me what do you mean by stereotypes what are the stereotype annotations stereotype lavender like the annotation first and save the bill like at the red component depository yeah the components eligible component repository service service controller and also don't tell the annotation which has the component inbuilt like rest controller or controller advice or uh configuration these annotations already have you know component in inbuilt right they are embodied component annotation so don't tell me any stereotype annotations uh tell me all the annotations like you know excluding all these things yeah can i tell no repository being yeah yeah yeah yeah why not yes okay so heart rate no repository beam so we annotate this bean whenever we don't uh want that class to be picked up by the container and instantiate it can you take all the get mapping post mapping all these kind of yeah why not yeah get mapping post like just tell me only one then put mapping delayed mapping okay so after eight uh put mapping i'll take this um and we have um many many annotations boot uh other it's a data jpa test at the rate no i should not tell that that's fine you keep on telling i know you know many at the right data test i'll be accepting it spring boot configuration after a springboard application uh at the rate i should not tell upgrade configuration either it being uh other age scope at the rate um [Music] what i'll be telling you i'll be giving you hint tell me three annotations from spring aop okay other eight aspects i know you know about all these things okay now let me ask you a very easy question you just told me about edurate no repository being as the first annotations okay before before i tell you to explain me that thing lavanya tell me one thing do we need to write a at repository annotations whenever you are using spring data jp for an example the way you want to you know you know have a class which is which is going to give you all the fraud feature inbuilt in springboot what we do we use the data jpa project we are the string data jp as the startup and we're going to say we will be creating an interface we'll extend that to jpa repository or fraud repository or uh what we have like in a paging or sorting deposit right and on top of that interface do we really need to write a direct repository annotation if yes why if not why question is clear yes yes yes so first we don't understate repository so basically uh what the spring uh boot bus with this dependency added is we have uh other eight enable auto confection run in background there is a generic class implementation for all the repositories what you have told like jp repository the main one is the crud one which has child sorting and paging repositories and jp repositories so this has a generic implementation of crud repository or gpa repository so that class would have annotated with at the rate repository and this class what we write will rely on that the the beam which is created by the generic implementations of this crud repository will be injected with the dependencies of our classes which has bought to the repository custom repository that we created so it is not necessary to add at the rate repository on interface only with the class secondly um at this point i am not a little clear-level i i understand what you said so are you trying to say that okay we already have our dependency in place correctly so let's say data jpeg dependency i added to my project now i'm creating a interface let's say some xyz interface which is extending to jpa repository right now in my interface i don't need to write a repository annotation correct because it will be automatically detectable because spring boot will automatically detect uh the jpa related because our interface is already extending to that one so there is no need to write the add repository annotation on top of our interface correct people i have seen people they keep on using at the right repository annotation on top of the interface do we need to really add it no but is it really required no it's not required right yes because even though you are writing it repository annotation on top of that particular interface the implementation we will not be generating implementation spring boot will be generated right so spring boot will be generating the implementation for that particular interface will give us all the crowd feature is this list to me my next question tell me what is the difference between jpi repository crowd repository um your paging and sorting repository tell me the hierarchy and tell me a little about spring data jpa project that we have right so yeah keep on getting your thoughts on that yeah okay so base repository is a repository which is a marker interface and the next layer is crud repository wherein we have all the correlated utility methods create update save and the next interface is paging and sorting repositories and this repository will have a utility method related to sorting and pagination and the next repository is jp repository this gpa repository will have all the methods like get find um and delete and patch save all and flush all these kinds of utility methods will be available in the gpa a repository this is the hierarchy and uh when we create a gpa project you are asking about the gpa project yeah just tell me a little bit about the data like you know why do we need that what spring whatever you told us perfectly that's the thing that i want to hear in love yeah you said repository this is one then we have uh cloud repository then we have uh paging and sorting this is the base right repository oh sorry if your interface does not need although or if you want to generate something we does not need any crowd feature directly extend it to repository if you need only the cloud feature only extend it to crowd repository if you need paging and sorting and everything then you extend it to the paging and sorting repository right now you are saying jpa repository right where come the jpa depository is coming from it's coming from the spring data project right what is spring data okay normally if we create any uh project that has some relationship with the database we create the interface and we give the implementation class of that interface and try to connect up with the database for example if we say a raw jdbc application or even spring jdbc we write the queries we open um our data source the connection and we save everything and we close the connection and uh and close the connection and make the transaction to be done safely but here in spring data it is a layer in between the the provider implementations the data implementations and the database we rely here and the spring data gpa the next layer the next layer is the jpa provider layer the next one is the database so this what spring data gpa gives us it gives us basically data initialization first point the second one it gives utility methods which based on our entities that we create it automatically understands whatever the method that we write and it executes the query with the help of the jpa provider the default gpa provider is hibernate what is it oh yeah hibernate yeah go ahead this is what i wanted to hear go ahead the next point is it's with the help of this enable auto configuration which is a beautiful feature wherein it create the entity manager basically the session of the persistence context and uh next one is entity manager factory with the help of all the data source details that we give it automatically creates the factory and gives us the uh the entity manager object whenever it is needed the next point is the transaction it takes care of the transactions as well we just uh we just extend one repository that is called jp repository with the help of that we can create our own functions for it with with stuck yes yes okay one second it's fine right now yes sir now it's okay but last 30 seconds oh i told you in a reason you know it was thunderstorm and slides right now i'm in my native love and it's like a little far from the city and it's kind of a hilly a beautiful place to stay but in summer right in the evening specifically um there was no internet and just right now it's it's blinking that's why i connected with my internet and also my mobile internet so if anything goes down one will pick up or anything will happen i know you are available you can connect again here one thing only i wanted to ask you that point that you have added here the gpa repository is giving us all those implementation and the default provider is your hibernate right this is one actual point i want to hear because this if you are using instead of spring data gpa if someone wants to put spring data dependency for mongodb data is a framework which is a abstraction abstraction for any database api which want to connect to your application right spring has a abstraction under the data umbrella we have jdbc we have hibernate mybatis mongodb cassandra um so and so so let's say you are the three on three interface you have set repository jpi repository and one more paging and sorting repository repository crowd repository and paging and sorting repository these are the three best and then if you are using spring data as apa then your jpi repository comes in which the default provider is if it is if it is a repository then same thing your your you will be extending to the mongol one and the mongol one will be extending to the paging inserting then crowd repository then the red deposit jpeg repository for hibernate that's why we have repository for mongodb right but that three interface that you have explained that lavini has explained is very very important that is the best so maybe people will ask you so many questions on this so be sure you understand this now lavender let's come back to the next point now you told me that if you want to create a new functionality just create an interface and extend it to jpeg repository things will work fine no need to write at the right repository it will spring will automatically detect the data jpa project and it will bootstrap your application it will create the implementation of your interface and you just need to use the methods i'm absolutely agreeing on that now the next question now or if you're gonna go for gpa repository or crowd repository okay or paging and sorting repository you're gonna be seeing an annotation called at the red no repository bin explain me the reason why they are writing that or can i write it in my own classes let's say i have an interface let's say xyz extends to jp repository can i put at the right no repository bin on top of that particular interface yes and not tell me the region yes yes like we can even add the no repository being to our class which actually extends the jp repository when we are adding that we will not be any uh the pin of that interface will never be instantiated with any implementation classes available here though we have implementations of this jp repository that will not be uh instead that will not be assigned to that interface so we will not be able to use that or the utility methods of this jpa repository for example if we have a class and that class has extended the jp repository consider the parent class has extended the jp repository i have some few utility methods defined and we have a child repository that extends parent repository so i have defined some of the utility methods also in it so at times i feel this child repository need not to be instantiated the parent repository is itself is fine too uh is enough to uh consume all all the utility methods given by jpa so at the time what i do i will add at the rate no repository being on top of this child repository so the spring container will never pick up this repository and create a beam for it and uh there will not be we cannot um add this add at this class as dependency to any other project perfect perfect this is one line i want to hear from you if you do not want to initialize an interface or you don't want to create an object for that interface because runtime spring only give you the interface implementation correctly so if you don't want spring to create a implementation for that you don't want to initialize that interface are that no repository so it will not create the object for that for which because someone if i have my own interface which is implementing or extending to jpi repository crowd repository then why to create the object for cloud repository why to create the object for the api repository just directly create the object for my interface if my interface also has another child class uh we let's say we are inheriting some property from our parent class so directly use right now repository on top of on top of our parent interface as well so that only spring will instantiate the child interface right perfect yes this is what i want to hear hopefully uh this is going to help you guys and this is one of the very popular interview questions what lavanya answered beautiful okay thank you very much next question here tell me the limitation of java config file okay tell me what is it what eleven yeah when whenever you see my voice is breaking and whenever you see you know the videos are getting a little blurry uh just let me know right so that you know i will take necessary steps also i'm recording it from a different camera but that will give me a lot of work you know how lazy i am to do everything and all right yes you're good but for the first time when i saw you it was much more clear than this the only thing i feel is that the first time i say sometimes your movement is a little bit large like this yes okay okay so now okay or okay okay they want to capture and send it to you the image that i see yeah sure so that i can see it is it manageable or not manageable yes yes manageable the voice is very clear no a little blurry huh let's follow it little bit little bit manageable okay yes [Music] do [Music] so the next question will be what do you mean by a java config file in spring okay tell me a bit of advantages of it little bit if you're comfortable and tell me what are the limitations of java config file in spring okay and do we need to use a java country file in spring or we should avoid it go ahead okay okay first java configuration is we are giving all the configuration details or the metadata of all the classes in a one java class not java file that is called java config and that class to be annotated with at the rate configuration this class is considered to be as a java config class and we can define the beans what what the spring beans definition can be given inside this configuration class with the help of at the rate beam so the you can you can annotate the service you can annotate the controller classes and all uh other uh implementation classes and everything in that in that java class itself so what are all the advantages i see is in the xml what we do we we actually create a bean tag open tag close tag and we have to write many uh many kind of uh names or attribute names in it so here that is not needed with the help of other 18 we can easily create an object and we can name the bean easily with the help of the attributes like uh other eight being open and we can give a name to it and but defining this uh all the beans in a java class we can restrict we can get hold of the beans like we can we can make use of other conditional annotations like conditional on being conditional on missing bean kind of thick and we can actually uh we can actually have get a hold when that object can be instantiated we can we can make put some conditions to the spring container on the beam creation uh then what i see it's a readability it's a readability and we can have multiple configuration files as well and we can interdepend them by adding it as one of the dependencies so uh here the java compiler put a constraint whether this configuration file is uh not final and it is uh inside the package so we need not to worry about whether we can uh inject inject add as an add another configuration file to the parent to this configuration file and we can also import any xml uh defined configuration files also in this java config with the help of other eight import resource uh the limitations what i see is because we need to add one more advantages before we go for the limitation i think you covered everything one important thing lavender you should know we are using admin and add bean tag uh sorry bean tag in your xml right and let's say your one bean got a dependency then how you are injecting the bin you are using ref you remember from your own yeah properties ref tag we are using and we are where we are giving the object but in the ref we can give anything we can give any bean object and it will not complain it will compile fine in the run time only it will give you error but whenever you are using the red beam and whenever you are doing java configuration let's say for dependency injection what you will do you will create constructor or inside the method parameter you will be you will be having the arguments and whenever you will be injecting any other bean there then it will be giving compile time error right the code only will not be compiled that okay the reference is for of this class you are injecting the beam or injecting the object of another class the java compiler will only complain so the compile then check will be there but in uh xml any dependence if you're rejecting let's say class is xyz you are injecting the object of uh let's say fff then also it will compile right so yes so this is one more advantages now coming back to the limitation part go ahead yeah limitations what i see is we cannot um have this configuration class as final because uh the the cg lib of the spring framework will create a sub class of this configuration class and they will take the ownership of uh when to when to call the actual spring beam definition method and when to create a proxy being in it so perfect yeah final because the java config file we create we define beans in that the things that you have told but actually the that class will not be invoked what can you tell me why lavanya so guys you know uh just want to repeat lavinia's point what she said is absolutely perfect that java config file will contain bin and that that particular class will not be invoked directly we will be creating proxy out of it right we'll be creating proxy out of it and the proxy class will take the control of create creation of the beam so it will be only invoking the bins right so the proxy will do the job now uh if you are making your classes final then cg leave has the limitation that it obviously need to extend the class and it need to overwrite the methods so if the class is married final or if any of the methods are also marked as final there is one more point the methods also cannot be final if either the class or the methods then it cannot be extended or it cannot be overwritten because the cg leave with the way it creates the proxies it extends to your class only then is overrides the method and give the implementation it will call your beam method only but before that after that it will do some checks now i want to hear what checks checks of the proxy class implementations okay i think one little thing okay i'll ask you one thing tell me uh what is the default scope of a pin singleton perfect what about someone will keep on walking a bean for many times then how many beans will be created many beans yes it will value the single turn property right because the default is singleton so that's why they are creating the proxy and creating the bean which is singleton they're making so that it is singleton so next time also if something will happen that restriction is there that you cannot create many [Music] yes yes now it's fine all right so from where i need to repeat someone like uh for the singleton class to not to breach the singleton property perfect from there yeah so yeah so that's what i'm saying lavender so basically if you have the single turn like in a spring default scope is singleton so you know um the proxy is there to check if the singleton property is getting violated right so if it is getting violated then you know it will just throw us exception that okay the default scope of the bean has been marked as a default scope of singleton you cannot create many beams out of this that's why you know we got a proxy class in the proxy class override your bin methods and execute and creates bin out of that but it also makes sure to do some validation checks like whether the singleton properties are not getting violated and there are some other things also we will not get into that two limitation i'll be taking out of your conversation uh class cannot be final method cannot be final and one more thing lavender if you have many uh and many classes then that particular file will be messy isn't it like you will be keep creating many bean definitions but one good thing you have told lavanya i want to bring that to the notice i haven't uh interrupted then add component and add bean you have separated this beautifully i want you to talk a little bit about that what is the difference between a direct component or what is the difference between creating a bean with other component annotation and creating a bean with other uh bin annotation okay you have told about that a little bit now tell a little bit more learning okay both the similarities is like both will be managed by spring container and both will undergo the life cycle of spring beam both will be undergo there is no difference the difference what i say is when we annotate a class with other it component and under its service work on the controller it generally creates a beam condition less with conditionless so the beams which which are created with at the right service or component will be unconditionally it will be created but when we define uh when when we have the pain with on when we have a method which is annotated with other rates other annotation being we can use any conditions on top of it like at the rate condition on missing beam at the rate and condition on class for example the spring also uses other it enable auto configuration and it uses all these conditional annotations in order to instantiate any beam like dispatcher servlet or view resolver or any jpa entity manager factor jp repositories everything has uh used this other conditional annotations to in order to instantiate it being as a break perfect perfect so basically you know you said that at the rate component means that the net service means that the control domain directly will be created here in the configuration file if you are annotating android b that means you are taking control by using control like you know when the either the p need to be created if that class is present then create the bin if this class is not present then create the bin if this bin is present inside the application context then only create the bin you can have many conditions out of that perfect lavanya i'll tell you a lot of a lot of people have this problem um you know when they they have been asked him questions like you know but tell me the difference between creating a using this and that okay let me tell you there is no electricity right now i'm comfortable okay comfortable yeah yeah i'm comfortable i'm comfortable uh there is no air conditioner running but everything else is fine okay if i feel a little uncomfortable then i'll tell you okay because it's midnight right now people who are watching is midnight for me it's right now 12 46 okay i'm pretty fine thinking to go for three hours coding after this all right so i think i'm okay i'm having fun let me tell you very honestly you are doing a very good job okay next question so the next question i'll ask you tell me what do you mean by bean post processor in spring bean post processor okay bean proof processor don't tell me about bean porch processor tell me about bean factory post processor first bean factory post processor is an interface which has a method post process uh beam so here we when a class we can create a class we can implement this interface and when we implement this interface all the classes which we implemented this interface will be instantiated very first by the application context and we can get the control into that class and what basically this interface works on customizing the metadata basically the java configuration or the xml or whatever the beam definitions which we uh defined in it so uh its feature is nothing but it can it can change the metadata but it can have the beam definitions loaded into it but not the beam is instantiated so here what the future what we can do is we can override we can give any other implementation to a beam whatever apart from whatever we have defined in the main java config and we can make use of matching the runtime values from dot property files that also we can do it uh yes all these things and one of the disadvantage what i see is uh you cannot uh make the beam to instantiate there because uh on doing that it will not be uh going through the proper life cycle of spring being basically it will not go through the post uh construct and pre-destroy methods so one that is called premature yeah so being post processor comes before the bean get initialized is it analyzed yes bean factory post processor comes before yes sorry bean factory first processor comes before the spring got initialized and after the spring curtain is analyzed if you want to do something then you go for bean porsche processor yes factory push processor factory push processor is like in a metadata control what new properties if you want to add if you want to control the definition of the beam so what you whatever you have inside your java config file defined before that beam is getting created you want to do certain stuff for that uh or stuff with that particular definition of the beam then you want the beam to be created and after the pin is activated if you want to take a hold of it then you go for the other one [Music] all right so before we go for the next section of the interview i think we haven't discussed much of coding related stuff right here so i just want to give you a very quick walk through to the bean factory post processor example uh well ignore the project name it should be bean factory post processor so let me explain you that particular thing in a very little example so imagine you got a component called test so right now i'll go to my test class and imagine it is annotated with it component annotation and it is getting scanned by the container so let's say you got a config class which is a java config class and as you can see inside this config class imagine you have a component scan annotation and inside this component scan you are scanning all the packages which is starting from com right so in this case the taste will be scanned and the bean will be created by the container but let's say before the bean will be created by the container i just want to control the beam definition i just want to control like what will be the scope of this beam or whether the lazy need to be set as a true or a false i i want to set the auto aware candidate i want to change the definition of the bean and if i want to do so before the initialization of this particular bin before my container creates this particular bean i can trigger a bean factory post processor so i can create a class and this class name will be a custom bin factory post processor let's say okay and this class is right now going to implement to an interface and this is going to be an interface called bean factory post processor okay and right now this offers you a method which is going to be a callback method will be automatically called by your framework and this will be automatically called whenever your container will be started and right now you got a bean factory in the argument so right now from this veen factory you can ask this vin factory to get all the bean definitions and there you go been definition names just get me all the bean that you got as a definition and now i will be having hold to the all the beans that i got inside my container and um right now what i can do uh i got a string array over here so i can do a for each loop i can iterate over this bin let's say a string being a definition name and i can iterate it over this array that i'm getting and i can get a hold up hold to all the beans that my container got to create so let's say i'll be doing the bean factory and i can just to get bean definition and i can pass this bin definition name right over here that is going to get me the definition of a particular bean so if i'm going to do a assign statement to a local variable as you can see this is where you've got the bean definition of a specific bean and you got you can you can manipulate it in any way for now let me just simply print this bin definition and let's see that what is going to happen so sorry the spin definition let me print it over here and there we go let me start my application and to start my application i got a main class called after java and inside this main class let me just format it a bit and let me create a application context so application context context is equal to new uh annotation config annotation config application context and right here i will be reading my config file and in this case my config file is this one appconfig.java right so copy this guy go to my after java and do upconfig.plus and right now do a right click run is java application and i'm expecting here that my custom bean factory to trigger and right now my custom beam factory post processor is not triggering and i was expecting that this particular method will be called automatically and it is going to print all my bin definitions right to the console but it did not happen because we did not initialize this particular bin and in order to initialize it right now i'll go to my config file and i'll create a bean for this i'll do public uh what is that custom bean factory post processor this particular class that i have created and i'll create a um you know bean for this and i'll do return a new custom bean first factory porsche processor i'll make it a bean and i'm going to say the bean there we go but also i'll make sure this bean should be initialized before any of my beans any other beans if i got any other beans right over here if those beans are defined over here before all those beans this bean need to be triggered and to make it happen i'm gonna make it static and right now i feel this bean will be created first before any other beans created and right now i will go to my update java do i right click run a's java application and i was expecting that all my beams to be triggered over here and as you can see right now is printing uh this for loop that we have designed right now is basically doing its trick and right now we are printing all the bean definition and if you want to see there are a few bean definitions as you can see these are all framework related classes but if you want to see here you got your class as well which is a test class remember this is the test class we had in the first we have designed this component which is this one and right now you can see the definition of the test class like the scope is singleton and the abstract is false the lazy in it is null auto where mode is zero and dependency check is zero all this definition that you are seeing all these things you can actually um you know it can change it you can manipulate this particular thing for an example if you want to change the definition of this test class and you want to change the scope to prototype you want to change the lazy you need to let's say something else let's say true then how can you do that you can go to your bean factory post processor and you got you got to go to your post processor bean factory and right here let's say i'm printing all the definition here and now i can do a check i can do if in i can just do let's say if this vin definition that we are getting if this bean definition uh dot get bean class name okay dot uh contains or dot ends with okay if the bin class ends with this one test let's say bin uh this this one ends with test let's say if we are having like because we're gonna be having many wind definitions now and we'll be looping over all the bin definition lamp but i want to change uh the definition of the beam test and this is the name of the beam so i'm just checking that if the bin class name is test and right now i can manipulate it like i can do pin definition okay dot set and you can see you can set a lot of different things let's say i want to set this particular scope that i got over here i can just do set scope and i can set the scope to let's say a prototype previously it was singleton and i'm changing it to prototype so let me say photo type okay and let's say previously the lazy indeed was no i want to change it let's say pin definition and i want to change the lazy init okay and i want to set it to true initialize it lazily um so if i want to do all these things i did change the you know definition of the being called test right now let me print it again let me copy this and let me just print it after this if ends and right now if you're gonna go over and relaunch your program you'll be seeing where is my test now look at that previously it was singleton now we have changed it to prototype and the lazy in it is true perfect so what we understood here is that before the bean got initialized you know we can take the control and we can modify a bin definition of a beam like this this test and the way it will be initialized the way the auto where candidate will be set what scope it will have all the things we can change and control by using the custom bean factory first processor okay that we have designed which is which is implementing the bean factory porch processor hope it makes sense so we have a very amazing first half of this interview and looking forward to have a very amazing second half by discussing a lot more interesting questions with lavinia but i think it's time to take a break so if you are tired enough here we go you can take a break right now and come back whenever you are ready and can enjoy the second half of this interview so you can safely pause this video right now grab a cup of coffee and enjoy the rest part of this interview right after a break [Music] [Music] recording in progress all right started the recording yeah i think to get worried i am recording here in the zoom i'm recording from my camera i'm recording from my camtasia recording for my webcam as well so one recording will get right so we are on internet so all uh all the security brother filter chain is in place so yeah i have security protection in place so if one will bypass then one will attack right perfect good so that brings me to security filter chain but i'll not be asking you that you are pretty good on that all right yeah so lavanya let's go for the next question tell me about the transactional propagation this whatever you understand about the transactional annotation and tell me what do you understand about transactional propagation right a little bit like you know i just want to hear like what is that okay so basically transaction has so many features in it so first when we can annotate this transaction on top of a class and on top of a method for example when we have a method annotated with other transactional and all the method execution will be taken care by internal proxy classes so so for example if we have a controller service and repository and we have a three transactional in the service layer so there will be a class that stands in between the controller and the service so that class will start the transaction and call and put the entire method in that transaction and then it will uh once after the commit or once after the execution of the queries are done with the help of the repository calls everything will be committed by this class so so this will take care of the crime which proxy is that dynamic proxy dynamic proxy and who manages this which module of spring transaction or spring data that proxy that face gets created which proxy is that dynamic proxy uh invocation handling location handler interceptor aspect aspect aspect j weaver aspect jv or spring aspects spring aspects of spring aop basically manages this cross-cutting concerns because transactional uh transaction is a cross-cutting concern we don't need to write those transactions in the beginning of every method or in the end of every method rather a proxy just said that is going to be involved with this and the proxy will be taking care of calling your service method or your repository method and on top of that it will start the transaction and it will commit the transaction right if something goes back or something goes wrong it will roll back the transaction so nothing bad will happen in case of any exception occurs which kind of exception run time or compile time run time exceptions what what will happen if it will throw any compile time exception compile exceptions we should handle it we should handle it let's say i'm throwing some exception which is not run time and i'm not handling it i'm throwing it to some other method and this is the method which is calling the method uh that is also throwing that particular method to some other method then what will happen if so i want to hear that if the exception which is occurring inside your method if that is not a runtime exception then do you think your transaction will be rolled back no it will not be rolled back so when compile time issues happens it will not uh the the x the basically the exception will not be propagated to that proxy layer the proxy class layer okay so you are saying it the transactional annotation only will roll back the transaction if it is a runtime exception so a transaction will not roll back if it is a uh you know if it is a normal exception which is not runtime correct yes okay perfect i understood that particular thing transaction means wrapping out something under a transaction block so if something goes wrong it will be rolled back now here comes to the propagation label that we can define along with our at transactional annotation you know right inside the transactional annotation parenthesis we can define the propagation now tell me first thing what do you mean by transactional propagation in one word okay so basically this propagation mean carry forwarding the opened transaction or the current transaction to the next level like the the next level basically from service to repository this transaction should be reusing the transaction transaction reusing the current transaction and there are various kinds of propagation levels also there so one of that is a require the default is required requires the new requires new in the sense for example if we have a service and there we have other transactional and that calls an interface utility method and that that is a repository utility method and that repository also is annotated the method is also on it with address transactional the propagation level is requires new so in this case what happens though we have any uh transaction is on active transaction is available that will not be taken into consideration and we will create a new transaction and will commit everything inside that transaction basically all the statements which are in that method will be executed in a new transaction not the existing one so we have uh next one is uh mandatory so mandatory in this mandatory propagation level that should always be exceptional sorry active transaction be available at this point of time when whenever there is no exception in the active sorry active transaction is available in the repository it throws an exception so that is mandatory um one transaction need to be there before you call that particular method non-transactional method is calling a method which is uh marked at transactional propagated propagation level and mandatory then it will throw an exception one accepted there is no active transaction is there you also explained about the request new request new means even though the service method which is calling a repo method you have given an example that says both the service method and the repo method is marked as ad transactional uh but the repo method has been marked as a transactional requires new then what will happen when the service method will be start then obviously the transaction will start but when the service will call the repo at that time even though there is a already active transaction as we as our repo method is annotated with at transactional propagation label is request new it will create a new transaction instead of using the service method which transaction that created right instead of using the current transaction it will create a new it will create uh the new transaction right the default one is required requirements okay you haven't explained the required a little bit explain with the required uh propagation label what do you mean by required let's say there is method a method b method a is annotated with a transaction method b is also annotated with a transactional you said even though you are not defining anything the default will be required right propagation label will be required what will happen a is calling b all right both are marked with a transaction at transactional then tell me what will happen so both both of the methods are transactional propagation level is required so first when we uh when we call this service method there will be a transaction will be created object will be created and that's the active transaction available so when a service call the repository method which is also an update with other transact transaction it uses the active transaction which is provided by the service and tries to pull in all the method statements into that transaction and once for all it will commit perfect now i have a question here if the service let's say method a service method b is your deposit to your doubt let's say the service method or the method a now we can think of method a method b method a is calling method b method a is not annotated without the right transaction it is a non-transactional method now method a is calling method b but method b is annotated with ad transaction propagation level as required right now what will happen it doesn't have an active transaction whenever method a calls the method b method b will look for a transaction because required will not create the new um you know transaction you said at the first the first transit look for the equipped transaction let's say the active transaction is not available then what will happen so it will create new one there so see when whenever the service is so not providing any active transaction to the repository it will uh create a new transaction that's what i want to hear can you tell me a last one i'll ask propagation label as not supported what it will do okay okay not supported correct here for example if we have a service which is annotated with other transactional and we have and that method calls the repository um repository method which has annotated with authority transaction and propagation level is not supported so in this case the active active transaction the transaction is open and the service level itself and when we call that method it will throw an exception telling no transaction should be available when this method is executing so it will throw an exception in case if active transaction is available at that moment at that okay what what i can do here so if service uh you if method a which already is under a transaction is calling method b which is marked as propagation level is not supported it will throw an exception because a transaction which is already active is using that and it does not support any transaction that is the use of not support not supported i will now what what i will do here if i want to avoid that scenario i want if the active transaction is there i just want to cancel the transaction or suspend that transaction and execute the transaction of the method be non-transactionally i don't want to throw exception in that case which propagation i will the propagation level i'll use even i don't remember never never yes never i think never will do what if any active transaction is there then it will suspend it and then it will just execute the method non-transactional perfect will not get into that guys you know if someone is hearing this conversation and getting mad like you know what's happening here um uh we we are recording some sessions lavender maybe your best lessons i'll be pushing it to youtube or to some free repository free playlist go and use it right there okay maybe um check the description for links and if that is if the links is not available please wait for that i don't know when i'll editing that and when i'll be posting it so okay now let's go for the next one yeah i have written something proxy one you have answered that transaction will use aop proxy here all right next next the question level now tell me the difference between the update method and the merge method in hibernate take your time explain it okay basically we have a session involvement in the hypernet so when we want to update any row any row value in a table first we will we would like to load that particular row as a entity into a session we basically load that object into a session and we make that object dirty that means we would like to change the state of that object that is changing the value of the attribute from a to b so whenever we are again adding uh that is session dot update and push the dirty object into that session again the automatic dirty checking will be happening in the framework level that means uh all the attributes of both the objects the session load objects previously loaded objects and the objects we changed the state so both will be compared at granular level like each of the attributes will be compared and the updated value that is the value which we have changed will be patched up on the value the already the session hold was holding it so and then on flash it will directly uh update the value into the database so the this is update so consider a scenario this is i'm going to tell about the merge now so merge when we load a object into a session say for example we are loading an employee object with id three and suddenly what we are doing we are closing the session we are closing the session the object becomes a detached one with the session and we are changing the state of that object say the employee name is changed from a to b so now what we are doing we are again opening a session and we are loading the same employee object from the database so now that object will have only the old values we'll have the old values now what we try to do the already the object which in a detached mode we have it in a hand and we have a session which also has the object with the id the same id it's loaded from the db and we try to update we push dot update uh with the detached object into that the newly created session so here we encounter exception telling uh non unique object exception non unique object exception might occur this is because the session cannot hold two objects with the same id perfect so here if we add dot merge what what happens all the the detached objects update what we have done on the and the detached object will be patched upon the object which the session holds and on flash it will be flushing the values into the database and on commit it will be completely committed yes look guys you know i've explained the same concept in a session taking one and a half hour 15 minutes five three minutes right opec lavender someone getting confused with this explanation please go and watch that one and half hour video and come back and listen to this physical mac perfections i think levine i have pushed that particular session to youtube already someone is watching this video as a paid uh video in some paid playlist uh go and check your spring and hibernate bootcamp only we have questions yes so yes what's the update versus march maybe the lesson for lesson five and hibernate isn't it yes for that the one take away one line i want to wrap up one session containing two objects and all the two objects will have the same primary key or the same id that time the session will be confused like okay which one i want to update either this one or this one we will say hey merge the value your screen is stuck okay oh no no good now good loving no no no no okay ah now good now good now good maybe it's just flickering a little bit all right perfect fine um perfect pennsylvania but you didn't finish it i think that you have already answered it it's good whatever you said okay um okay one more springboard questions loving yeah here to hear this question a little carefully you got two files application.yam applications application.properties file in application.yaml file you know that you can configure springboot properties using either application.xml application.ml or application.properties file or you can use java command line arguments or java environment variables to control the springboard properties right now i have a question let's say you got two files either you can use application.tml or you can use application.properties the application.properties file and application.eml file you can think like that using both we can configure our springboot project but my question here is that a developer either need to choose a application.tml or application.properties in order to work in the spring project let's say i'll be putting both of the both of this file application.dml application.properties both of the files are in my springboot uh class path where the file will be automatically detected because you know right this file will be automatically loaded in springboard application we don't need to lower it separately my question here is that if you got both the files inside the class path so do you think your application will start your springboard application will bootstrap or it will fail no i i think the it will start the application properly it will not uh fail then let's say uh i have a property uh in the application.properties file called name equal to lavanya okay and i have the same property in the yaml file called name equal to oblash okay okay and the application start now i'm trying to access the value of name in my one of my java class using add value annotation and i'm trying to print it now spring will print lavenia or avalash a village is in um ml file um let's is in yaml file lavanya is in properties file then which one will be uh there in the console which value will be printed the dot property file exactly so first yml then the properties right this file will get the priority because it will be loaded by springboard later okay so yml will be loaded first then the properties file perfect so i'll go for the next question um so i think i i'll ask one more question lavinia tell me how is dispatcher servlet in springboot got set up okay how the setup for dispatcher sublet happens i'm actually trying to ask you about the auto configuration how the auto configuration works in springboard uh i'm just tweaking uh twisting this particular question in a little bit and want to know how the dispatcher subject is getting into track or getting into action in springboard because we are not defining it by ourselves can you please tell me like how this auto configuration happens okay so in a springboard project we always add the dependency starter dependency for web application we will uh in order to create a web application we add spring boots web starter as a dependency and this dependency has a spring web dependency the transitive dependency will fall in place into the class path so we have dispatcher servlet servlet context the java x servlet api will also be part of this dependency and everything will be in our class path of our application so what happens when we create the spring boot application there are three annotations to be uh added to the main file the one is other a springboard configuration enable auto configuration and the component scan all will come together when we add at the right spring boot application so this enable auto configuration what it does it is um this is basically from a spring auto configure uh dependency project okay we have a spring dot factories uh file wherein all the co all the auto configuration beams should be created know all these classes will be part of that file so for example dispatchers will be available meta inf spring dot factories in uh spring auto wire project auto configure project yeah auto configure project meta inf folder factory is fine enable auto configuration and then continue yeah yes we have enable auto configuration and inside that all the auto configuration classes for example dispatcher servlet auto configuration and into jp repository auto configuration and um internal view resolver auto configuration as part of spring mvc we used to create the dispatcher servlet and the internal view resolver as a beans here so what it does it will go to the we we have already all fallen place like all the auto configuration classes are in the class path so here we have other eight conditional statements again conditional annotations again so at the rate for in the dispatcher uh servlet auto configuration class there will be a annotation called at the rate conditional on class dispatcher servlet.class what it means is basically it scans whether the dispatcher server.class is available in our project if it has it tries to create one and configure it with application context and that was under this dispatcher sublet will also be configured with the servlet context so this way the dispatcher servlet object is instantiated there will be also some other conditions along with that just fine that's fine perfect okay so it's all basically happens through the auto configuration when it detects the spring web mbc project in the class i got a question here what will happen if the spring wave mbc project with not there in the class path then okay then the web application context will be created or no it will not be created no it will not be created because there is no dispatcher uh servlet bean will be created as that context [Music] is not there there will be a normal uh what is that annotation configuration application context rememberation config yes yeah that application context will be created if it is there this web mvc thing is there then the dispatcher's outlet will be created although web application application context will be created if there is another one if the reactive spring you are using if you are having web flops then there is a reactive spring application context will be created based on the dependencies spring boot is smart enough which application contextual courier and the developer doesn't have any role which is a pretty stupid statement to say because if your client want you to configure it you need to configure it so you also need to learn how to configure dispatchers of it by yourself don't depends on springboard is good so like you know so far so good you know if you are using it properly and if there is no customization needed otherwise you know yeah i already i already told you guys right the manual car in the automated car you need to learn how to drive a manual car before you try to jump into an auto automated car driving the next question i want to ask you lavanya here i think i have covered pretty much everything i want to go for a question okay i'll ask you a tough question at last and then we'll wrap up uh before i wrap this off uh tell me how do you create java exceptions a simple java exceptions i'll mean one like uh that extends exception class check exception it tell me two lines then what will be the next exception uh i'll extend the runtime exception and we create a constructor with any uh string the custom variable you'll extend to either runtime exception exception you need to override like on the super constructor yeah perfect okay so tell me what is the difference between you know check the exception and uncheck the exception in java okay checked are like compile time exceptions for example file not wrong if we give any path which uh on in the compile time it tries to uh validate it so at the time we might there might be file that may not be present in the given path so file not form would be the compile time exception and uncheck are the runtime exceptions the arithmetic array index out of bound exception and the spring all spring exceptions like spring beam creation exception all these are runtime exceptions perfect perfect how do you handle exceptions in spring spring okay handling exp exceptions okay uh normally we have uh we uh actually handle this exception with annotation called at the rate exception handler and we define a handler method under it and it takes a parameter also what kind of exception it will handle and we can get hold of that exception and we can uh for we can format it in whichever way we want like uh we can have a a a basic or a model for handling the exception with the fields okay service exceptions yeah we can create a model like you know which will have the response type the exception date and everything and we can return that same object as part of the exception so the client will get the response with all the glory details about the exception exactly perfect you can use that using the exception handler method the exception handler method where you will be keeping you will be keeping it inside a controller or where you'll be keeping the exception all the handler methods that you have yeah all the exceptions it is it is uh it is it's not okay to keep it in the controller level at the global level we can take it and we can define a class where in all we can have all the exceptional angular methods in it to pick to actually make the class to work globally we have to add another annotation called the rate controller advise on top of it to actually get hold of the exception whenever the service or the controller throws an exception and handle it perfect so instead of putting our exception related code inside the controller itself what we can actually put there is obviously we can put it there will be no compile time issue we can move it to the global level using controller advice advice what is the difference between ad controller advice and address controller advice oh yes okay so here the response body at the rate response body plus other rate controller advice is equivalent to the other interest controller advice it will normally return as a response whatever we give it it will be re writing into http servlet response so this is the everything right uh okay perfect good so okay one last question in this talk what will happen if okay what will happen if your rest service is returning some exception like bad gateway like you know your client is trying to connect to an external rest service but that it is not able to connect it is not able to do a handset okay or it is trying to connect to a xml service it is able to connect but some time out is happening some read timeout is happening or some right timeout is happening okay then what will happen then how will you handle that we will that will that when that exception will occur do you think it will go to the controller advice or it will not go there it will not go to the controller actually exactly uh we can actually have a response error handler in it yes yes yes yes so like this response error handler is an interface which has two methods in it uh one is has error and another one would be handling the handle error so this um for example we call any risk services with other address template and that throws any gateway exception in it we can get hold of that exception in the other eight response error handler class so basically we can check the exception occurrence based on the http status that we get it so there is also one helper class like default response error handler through which we can actually detect whether the error http status is um not 200 it's either 500 or 400 so with the help of that we can catch the exception and customize the exception and the handle method and again here we can throw our custom exception and again we can handle it in a global handler which is annotated with other rate controller platforms perfect good job loving that perfect answer okay the next one yeah okay let's wrap it up but let's have a healthy five minutes five minute discussion on this tell me lavinia what do you mean by trade local in java normal plain java what do you mean by thread lockup okay and then we will discuss about the what is the real-time uses of thread local and if you have ever seen the users of this in any of the framework like spring hibernate or any of your java frameworks or if you are doing it in your real-time projects that you are working on right now just give me some instances like okay obvious this is where the thread local is getting used okay please continue okay so thread local is considered to be as a memory which is available to all the threads okay so when we take any console application any java application our main thread is a thread which has a local memory in it and that memory is called threshold local is specific only to that thread for example if a thread we can even have variables or any kind of object reference to a thread local and it will be bounded only to that thread though two threads are accessing the same object they can have the variable same but they cannot see each other one thread thread local will not be visible to the other thread so this is the this is my understanding of the red local and uh it is also can be considered as a scope like we see the request session scope in spring this also considered to be as a one of the scope so i see this as per the sea in the web application when we have uh spring security also part of it so i would like to tell the cycle a village where i saw so when we deploy application which has a security implemented in it the web server when when we hit the bib request the request comes and hit the web server and the web server assigns a thread to each and every request that comes in a request hit the web service web server and the web server creates a thread for the request and that goes through authentication filter and the filter will create a authentication object so i take username password authentication token which is an authentication object here we have the user name which we uh with the user entered and the password and also the couple of uh attributes in it for example it can have details details which hold the the ip address of the client and the certificate that the client has and is authenticated is another attribute which will be by default false on the first hit then it goes to a authentication manager and the authentication manager uh there is an implementation class for authentication manager is the provider manager what basically it does it tries to um delegate the token to all the available providers in our project for example there can be many available providers the username password authentication provider is one by default the next one can be basic authentication provider the phase authentication provider thumb authentication provider these are all the custom authentication providers that we can have in our application so this token will be moved to all the providers method called support and the supports method detects whether this object can be validated by this provider or not so i have taken username password authentication uh token as as my object and the username author username password authentication provider will say yes that it can handle that object all the rest of the provider returns false to the provider manager now this authentication this username password authentication provider will delegate this request to the further down level they use the user detail service which actually uses load user by username with the help of this the user credential we can load all the details of the user including the authorities or the rules um then its password it can and the password encoder will also fall in uh place and there will be a validation against the password entered by the user and the password which is stored either in the it can be any implementation in memory or jdbc or any ldap then on successful validating validation the the the object the username authentication username password authentication token object will be marked authenticated that is the boolean attribute will be changed to true and they are again it is given back to the authentication filter and from filter it goes to a holder a place called security context holder and this security context holder has the security context that is nothing but the username password authentication token mark authenticated and the scope of this object is thread local that is it is specific to that web request alone so if in case if another web request hits the server again the same uh same path goes on and it creates another username password authentication token and it be placed in a holder security context holder that mem that scope is also called threat local so the basic advantages of having it in uh it's um it's um having it in a thread is scope as thread local list we can handle this authentication object at any layer in our application either in the controller or in the service or even in the repository also if we need it to access so the the default scope of this username authentication for the token or the servlet context is thread local and this is one of the practical implementation i see the implementation i see perfect one very very comprehensive and very nicely answered lavender thank you very much for the detailed explanation yeah and i feel really good you know after i hear this language and explanation because i i feel very yeah thank you lavanya but yeah one thing i just want to point out maybe you have missed it but you know it that this this is very important to understand that this security context holder data will be cleared by the framework because the basic scope of that is thread local so any thread lock so it is not really recommended to create trade memories and make use of threading thread memories as a div you can do it of course but you know in framework label they utilize these things because imagine you know some users is authenticated right now let's say labanya is connecting to my web server then my web server has limited number of resources limited number of threats one trade is given to lavanya she entered her username password and everything now lavana is blocked in now my third local is holding an object about lavanya's information which is my authentication object now once lavanya locks out once c is locked out it is important that we are clearing that authentication detail what will happen if a village is right now right now lavanya is locked out now it is very important that that when the response will go back the thread will clear that object which is which is already holded by the thread previously which is lavender subject otherwise let's say you know the web server has limited number of resources right now i'm just say i'm connecting to the web server now web server is giving me the same thread which he has given to lavanya before and it has not cleared the thread local memory previously then lavinia's currency 11 years information will be already there so it will be if it will be given to me then it will be a mess it will be a complete stir right that is very important that the clearing is also happening like you know the thread clearing is also happen yeah very perfectly answered lavanya and yeah thread local means thumb memory that thread has internally it uses via the framework because framework because one important thing lebanese we both might have missed here that let's say in our dow layer in our repository layer in your service layer everywhere we need the information about the user so how you will be getting that object okay you will be asked to thread local so once the authentication object that you are telling lavender once that object got created in security that has been kept in the thread local so any layer you want to access the thread acts to the security context holder which is basically your thread local scope it has right the default scope will be thread local right but it has a monoscope also maybe this is the question for you guys yeah maybe let it for the people like who are hearing it if you know what are the other scopes are there for the three for our spring security context solder put it in the comment section one hint lavane has given you already don't repeat it so yeah the default will be through local so you know that will be there in the thread in your service repository any place you want to access that object just do security context folder get context dot get authentication object it will get you back the authentication object perfect that is coming from the thread local only just remember this much perfect should i ask you more questions i think i'm pretty happy with this much love in here and maybe a couple of quoting questions i'll give you you we will do it later maybe we'll just um add to the end of this video okay and apart from that i don't think you made my job easy i don't have to do much of editing in this video honestly telling you i've enjoyed it pretty much asking your questions i can keep asking you for next couple of hours it's 2 2 a.m already i will be go i'll be going quoting for three more hours as they said 11 year because i got some client calls tomorrow and again some interview got scheduled maybe you know i'll just i'll see like you know what i can do right now um yeah thank you very much lavena it's a wonderful wonderful interview if you want to send me something you can say it right now any feedback anything um you want to give on the interview or anything you want to say you can say it and then we can wrap it up no like uh yeah i i just wanted to tell something to you not to the or not to anyone thanks a lot thanks a lot for uh conducting this it uh really motivated me to give clear answers all for all your questions and uh you know that i'm i'm with you for last six months six or two seven months learning from the scratch of spring so really i got good cold about this spring java hibernate jpc who are having gap i think many of them lebanese to be very honest uh especially from a lot of female candidates i have like who are who are like you know who are having gap you know after because of some or some some reason every day i receive calls you know but i have i can see like you know they already have the things you you are going to be your motivations for a lot of them if they're watching it she has she has been to be very honest i am not praising her she is one of the very consistent uh you know attendees of every meetings that we had she was pretty much consistent with her learning so that's it lavanya you don't you don't need to learn anything more just go and give interviews i'm sure you'll be cracking minis okay and just send me some switch once you are done thank you thank maybe we'll do it later yeah yeah um yes uh cool i think we we are recording it for last couple of hours isn't it um yes yes oh it started around two o'clock perfect no problem thank you very much lavinia for attending the interview and i'll see you in the next not in the next video in the next lesson next class on wednesday on wednesday we will be discussing advanced transactional annotations deep dive followed by the microservices prerequisite okay bye bye take care have a good day nice talking good night good day love you bye [Music] [Music] [Music] you
Info
Channel: Selenium Express
Views: 173,334
Rating: undefined out of 5
Keywords: java interview questions, spring boot interview questions, spring boot interview questions and answers for experienced, core java interview questions, spring interview questions, hibernate interview questions, java interview questions and answers, java basic interview questions, multithreading interview questions, spring boot interview questions for experienced, java interview preparation for experienced, java interview prep, java interview questions coding, selenium express, mock
Id: ZzJ3qkPR9WA
Channel Id: undefined
Length: 99min 53sec (5993 seconds)
Published: Sun May 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.