Solved

loading mapping files dynamically

Posted on 2006-11-15
3
247 Views
Last Modified: 2013-11-24
Hi,
I am using spring in the combination of hibernate. I have a lot of mapping files(*.hbm.xml) that is configured at the in the applicationContext.xml
Everything is working fine. Since all these files are loading at the startup it's consuming a lot of memory. In the development environment this is affecting very badly.
I want these files to be loaded only on demand except at the startup. How do i acheive this

Thanks,
0
Comment
Question by:seekingsolution
3 Comments
 
LVL 5

Accepted Solution

by:
kannan_ekanath earned 125 total points
ID: 17946080
In hibernate, the mapping files wont be loaded until you call
sf.buildSessionFactory() If you are using hibernate directly dont make this call until you need it.

If you are using containers such as Spring, then you can ask *Spring* to not initialise the bean until the bean is requested,

http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-lazy-init

<bean id="lazy" class="com.foo.ExpensiveToCreateBean" lazy-init="true">
    <!-- various properties here... -->
</bean>
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now