Solved

loading mapping files dynamically

Posted on 2006-11-15
3
248 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 98
micro services vs rest web services 16 81
compre toata in where clue oracle 4 55
split string containing \r\n in Java 46 38
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

929 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

12 Experts available now in Live!

Get 1:1 Help Now