Results 1 to 2 of 2

Thread: spring 3.1: How to set property reference in java config define in xml.

  1. #1
    Join Date
    Feb 2007
    Posts
    291

    Default spring 3.1: How to set property reference in java config define in xml.

    Hi i have some session factory define in xml file.

    I have the following define

    Code:
    <bean id="company.sessionFactory"
    		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"/>
    inside xml file.

    I want to be able to reference this session factory inside my java config class.

    Code:
    @Override
    	public void addInterceptors(final InterceptorRegistry registry) {
    		// Changes the locale when a 'locale' request parameter is sent; e.g. ?locale=de
    		registry.addInterceptor(new LocaleChangeInterceptor()); 
    		final OpenSessionInViewInterceptor osivInterceptor = new OpenSessionInViewInterceptor();
                     // need to set session factory. 
    	}
    How would i do this?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    @Autowire the sessionfactory in your config class and use as desired.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •