Java tutorial
#set($symbol_pound='#')#set($symbol_dollar='$')#set($symbol_escape='\') /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ${package}; import ${package}.entities.Dummy; import ${package}.repositories.DummyDao; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Component; /** * * @author david */ @Component public class Sprodion { @Autowired private DummyDao dao; public DummyDao getDao() { return dao; } public void setDao(DummyDao dao) { this.dao = dao; } public void hello() { System.out.println("Hello spring!"); } /** * @param args the command line arguments * @throws java.lang.Exception */ public static void main(final String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml"); Sprodion s = context.getBean(Sprodion.class); s.hello(); Dummy entity = new Dummy(); entity.setAmount(10); entity.setName("Hello hibernate!"); DummyDao dao = s.getDao(); dao.create(entity); List<Dummy> entities = dao.findAll(); for (Dummy iter : entities) { System.out.println(iter.getName()); } } }