Saturday, April 1, 2017

What is Dependence Injection in Spring

         What is Dependence Injection ?

è The process of injecting the dependence into dependent obj.

è If underlying server/container/framework/runtime(like JRE) assigns values to resources /class/objs dynamically at run time then it is called Dependency Injection .

è If underlying server or container dynamically assigns the dependent values to out resource (class/objects) then it is called DI.

Types of DI:-

a)      Setter Injection
b)     Constructor Injection
c)      Interface Injection
d)     Method Injection

e)      Lookup Method Injection 

What is Spring Inversion of Control (IoC) in Spring JavaHighQ

                   What is Spring Inversion of Control (IoC) in Spring
?


The spring Inversion of Control(IoC) is responsible for creating the objects, managing then (with dependency injection (DI)) wiring then together, configuring them also managing their complete lifecycle.


Inversion of Control(IoC) or dependency injection minimizes the amount of coding in an app. It makes easy to test app since no singletons of "JNDI" lookup mechanisms are required in unit tests loose coupling is promoted with minimal effort and least intrusive mechanisms. Inversion of Control(IoC) containers Support eager instantiation and lazy loading of services.

Friday, March 31, 2017

Difference between Get() and load() in Hibernate

      Difference between Get() and load()   ?

ses.get(-,-)
performs early/eager loading of the record that means it loads record from database table to object irrespective of whether that object is used in further part of the application or not

ses.load(-,-)
method performs lazy loading of the records that means Hibernate framework retrives the record from table to object only where the utilization of the object is started  till that it gives proxy object to application.




ses.get(-,-)
ses.load(-,-)
      1.       Performs eager loading of object
      2.       Does not generate proxy object
      3.       Involves total one object of domain class in the loading of record.
      4.       Suitable to check whether record is available of not  
      5.       Returns null value when record is not available
      6.       Useful for immediate and granted utilization of record once the record loaded.
      7.        Useful in single layer environment
        1.       Performs lazy loading of object
        2.       Generates proxy objects
         3.       Involves total two objects of domain        class (one real one proxy object) in the  loading of record.
        4.       We should use this method by assuming  record is available 
        5.       Throws ObjectNotFoundException when  record is not available.
       6.       Useful for delayed of non-granted  utilization of the record once the record is  marked.
       7.       Useful in multilayer environment where the record marked in one layer will be utilized in another layer.



     Diffrence between update() merge() and saveorupdate() ?



ses.update(-)
ses.saveOrUpdate(-)
ses.merge(-)
      1.       Perform object updating/record updating 
      2.       Updating record without checking the availability of the record.
     3.       Generates only update query
     4.       Generates update query even through object data is matching that is available in the table.
      5.       Does not return any object representing the records that has to be updated.
      1.      Perform save/insert  of update operations on record
      2.      Update insert of updated the record by checking the availability of record.
      3.      Generates select query and insert/update query.
      4.      Does not generate update query.
      5.      Does not return any object representing the records that has to be updated.
      1.       Perform save/insert of update operations on record.
       2.       Update insert of updated the record by checking the availability of record
        3.       Generates select query and insert/update query.
4.       Does not generate update query.
        5.       Returns object representing the record that has to be updated of inserted

What is the difference between ses.save(-) and ses.persist(-) method in Hibernate

       What is the difference between ses.save(-) and ses.persist(-) method ?

ses.save(-) method gives instruction to hibernate framework to save object and also returns  the generated identity values back to java application where as ses.persist(-) does not return the dame identity value .

ses.save(-) method return type is “Serializable(I)”.

ses.persist(-) method return type is “void”.

Prototype :-

public void persist(Object obj)

What is the use of hibernate. Dialect property in Hibernate configuration file in Hibernate


What is the use of hibernate. Dialect property in Hibernate configuration file?

It is hibernate property that expects the api supplied sub class name of org.hibernate.dialect.Dialect class this class name will change based on the Database software and its version we use.

   Oracle 9i----à org.hibernate.Oracle9iDialect

   Oracle 10g----à org.hibernate.Oracle10gDialect


   Mysql5----à org.hibernate.dialect.Mysql5dialect

What is sessionFactory in Hibernate

        What is sessionFactory ?

        SessionFactory:- 


Factory to create hibernate session objects  Maintains the datea that is collected from configuration object(Both cfg file and mapping file data).

Represents JDBC Con  pool that is created based on cfg file data .
SessionFactory object is immutable that means the data of this object cannot be modified onc created.

It is the object of  java class that implementes org.hibernate.SessionFactory.

SessionFactory factory=cfg.buildSessonFactory();


Builds session factory object having inmemory metadata  of both xml files that is gathered throuth “cfg” object.that is created based on hibernate cfg properties of inmemory metadata. 

What is session in Hibernate

1.       What is session?

Session:-

Open the session/connection with database software from hibernate application.
Internally encapsulates the JDBC con that is collected from JDBC con pool represented by session factory object.
The main component in hibernate application to provide the form of objects Based  on  these instruction. Hibernate framework internally uses JDBC code with SQL Queries to perform persistence operations.
It is the object of java class that implements org.hibernate.Session(I).

Session session=factory.openSession();

Makes SessionFactory object to create 1 hibernate session object encapsulating the JDBC connection object  this session object is useful to maintain domain class objects and to  provide persistence instances of hibernate framework.