How to Autowire objects in Non-Spring classes / How to get Application context in Non-Spring classes / How to get access to the Spring application context In a non-Spring class


Imagine you are working on a Spring application where most of the objects are created using Spring annotations and fields are also injected using Spring mechanisms (using @Autowired or XML configuration). Now you develop a component or use an API which is written without any use of Spring and you need one of your Spring managed classes in it. (more…)

Continue Reading

How to configure Hibernate / Various ways to configure Hibernate in an application

Hibernate framework is used for interacting with database records as Java Objects and vice-versa. It saves/updates java objects as database records, fetches database records as java objects etc. Hibernate performs database interaction using its Session objects. Session objects are retrieved with the help of a SessionFactory. This SessionFactory is related to a particular database.


Continue Reading

How to configure hibernate without configuration file

It’s a common method to use a configuration file where database connection details, mapped entity details are provided which we commonly call as hibernate.cfg.xml or
It is a common belief that to start using hibernate we have to use a configuration file. But let me tell you that it is also possible to completely omit this file and configure hibernate alongwith a particular database directly from the code. Let’s see how: (more…)

Continue Reading
Close Menu