Project

General

Profile

Revision 582cd24e

ID582cd24e4df90b172bafab9d75f495e35874e4ae
Parent 42b7ab89
Child e14a8c4a

Added by Andreas Kohlbecker over 3 years ago

ref #6169 adding getService() method to CdmRepository

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmRepository.java
12 12
import javax.sql.DataSource;
13 13

  
14 14
import org.apache.log4j.Logger;
15
import org.hibernate.HibernateException;
16
import org.hibernate.Session;
15 17
import org.hibernate.SessionFactory;
16 18
import org.springframework.beans.BeansException;
17 19
import org.springframework.beans.factory.annotation.Autowired;
......
182 184
	private IEntityConstraintViolationService entityConstraintViolationService;
183 185
	@Autowired
184 186
	private ICdmPermissionEvaluator permissionEvaluator;
187
	@Autowired
188
    private SessionFactory factory;
185 189

  
186 190
	//	@Autowired
187 191
	//@Qualifier("mainService")
......
482 486
		context.setAuthentication(authentication);
483 487
	}
484 488

  
485

  
486 489
    @Override
487 490
    public IRightsService getRightsService() {
488 491
        return rightsService;
......
492 495
    public IRegistrationService getRegistrationService() {
493 496
        return registrationService;
494 497
    }
498

  
499
    public SessionFactory getSessionFactory() {
500
        return factory;
501
    }
502

  
503
    /**
504
     * Returns the current session.
505
     * A new Session will be opened in case of a HiernateExecption occurs when getting the current Session.
506
     *
507
     * @return
508
     */
509
    public Session getSession(){
510
        Session session ;
511
        try {
512
            session = factory.getCurrentSession();
513
        } catch (HibernateException e) {
514
            logger.info("Opening new session in turn of a HibernateException: " + e.getMessage());
515
            session = factory.openSession();
516
        }
517
        return session;
518
    }
519

  
495 520
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)