I have an SpringBootApp with embedded Derby;works fine. When I implement CommandLineRunner or @PostConstruct I get above error
"org.hibernate.LazyInitializationException failed to lazily initialize a collection of role:...- could not initialize proxy - no Session".
How do I create a session with Hibernate before the app actually runs but after the applications.properties file has been loaded? Also what is SprinBoot doing elsewhere that prevents this error in normal running?
 @Component
@Transactional
public class DatabaseTesting01 {
    private static Logger logger = LoggerFactory.getLogger(DatabaseTesting01.class);
    @Autowired
    EDITypeService ediTypeService;
    @Autowired
    VendorService vendorService;
    @Autowired
    SubscriberService subscriberService;
    @PostConstruct
    public void init(){
        Vendor v = vendorService.findOneByShortName("UNFI");
        logger.debug("Vendor:UNFI"+v.toString());
    }
}
UPDATE This is what worked.HTH.
@Component
@Service("database01")
public class Database01 {
    private static Logger logger = LoggerFactory.getLogger(Database01.class);
    @Autowired
    @Qualifier("transactionManager")
    protected PlatformTransactionManager txManager;
    @Autowired VendorService vendorService;
    @PostConstruct
    private void init(){
        TransactionTemplate tmpl = new TransactionTemplate(txManager);
        tmpl.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                vendorService.deleteAll();
            }
        });
    }
}