I was just wondering what is the best way to use hibernate & spring in our Application, like i have implemented hibernate in my web application. Every thing is working fine but the thing is i have a list of classes which i have in my applicationcontext.xml class Now when i need to use any of those classes I make object of this applicationContext.xml class as below
ApplicationContext ctx = new ClassPathXmlApplicationContext( "applicationContext.xml"); MySQLRdbSpringHelper rdbHelper = (MySQLRdbSpringHelper) ctx.getBean("ManagerJobs"); but by this method ,the program invokes all of the classes in application context.xml(below) in the List which uses more memory, isn't there a way to invoke the only class which we need one at a time..?
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>com.zrsol.joblistings.shared.Employer</value> <value>com.zrsol.joblistings.shared.StatesProvinces</value> <value>com.zrsol.joblistings.shared.EmployerJobs</value> <value>com.zrsol.joblistings.shared.CandidateResumeInfo</value> <value>com.zrsol.joblistings.shared.CandidateSkills</value> <value>com.zrsol.joblistings.shared.CandidateInfo</value> <value>com.zrsol.joblistings.shared.SelectedResumes</value> <value>com.zrsol.joblistings.shared.SecretQuestionsBean</value> <value>com.zrsol.joblistings.shared.Categories</value> <value>com.zrsol.joblistings.shared.EducationLevel</value> <value>com.zrsol.joblistings.shared.Salary</value> <value>com.zrsol.joblistings.shared.JobLevel</value> <value>com.zrsol.joblistings.shared.EmployerCvSearches</value> </list> </property> </bean> <bean id ="ManagerJobs" class= "jobsite.persistence.MySQLRdbSpringHelper"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
Thanks Junaid
|