hibernate não está nem tentando se conectar?
Oi eu estou tentando aprender hibernate 4 e SPRING 3.2
mas eu não posso nem conseguir hibernar para tentar se conectar ao DB parece. Desde que eu deliberadamente dei as credenciais erradas e ainda não estou recebendo nenhum erro. Eu tentei isso porque eu estava recebendo uma exceção nullpointer no meu controlador que é:
@Controller
public class HibernateDemoController {
private MovieService movieService;
@RequestMapping(value="/hibernatedemo", method= RequestMethod.GET)
public String index(ModelMap map) {
//map.addAttribute("hibernate", "Hibernate with DAO");
Map model = new HashMap();
//try{
model.put ( "movies", movieService.getAllMovies() );
//}catch(Exception ex){
// model.put("movies", ex.toString());
//}
return "hibernate";
}
}
O movieService
@Service("movieService")
@Transactional(propagation=Propagation.SUPPORTS, readOnly=true)
public class MovieServiceImpl implements MovieService {
private HibernateMovieDao movieDao;
@Override
public void addMovie(Movie movie) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<Movie> getAllMovies() {
return movieDao.getAllMovies();
}
}
O filme DAO
@Repository("movieDao")
public class HibernateMovieDaoImpl implements HibernateMovieDao {
private SessionFactory sessionFactory;
@Autowired
public HibernateMovieDaoImpl(SessionFactory sessionFactory){
this.sessionFactory = sessionFactory;
}
@Override
public void saveMovie(Movie movie) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<Movie> getAllMovies() {
return (List<Movie>) sessionFactory.getCurrentSession().createCriteria (
Movie.class ).list();
}
}
parte do meu expedidor-xml
<context:component-scan base-package="com.outbottle" />
<context:property-placeholder location="classpath:jdbc.properties" />
<mvc:annotation-driven />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<!--<value>com.springmvc.model.User</value>-->
<value>com.outbottle.hellospring.entities.Movie</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${dataSource.dialect}</prop>
<prop key="hibernate.show_sql">${dataSource.show_sql}</prop>
<prop key="hibernate.connection.pool_size">${dataSource.connection.pool_size}</prop>
</props>
</property>
</bean>
<bean id="hibernatemovieDao" class="com.outbottle.hellospring.dao.impl.HibernateMovieDaoImpl" >
<constructor-arg ref="sessionFactory"/>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>'
Alguma idéia do que perdi?