fixes bug#7791
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@58728 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
09aa056bc7
commit
ac194f9f5f
|
@ -0,0 +1,5 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
public interface FlywayUtilDAO {
|
||||
public boolean existeErroExecucaoScript();
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.jdbc.Work;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.orm.hibernate3.HibernateCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.FlywayUtilDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.EsquemaAgrupacion;
|
||||
|
||||
@Repository("flywayUtilDAO")
|
||||
public class FlywayUtilHibernateDAO extends GenericHibernateDAO<EsquemaAgrupacion, Integer> implements FlywayUtilDAO {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(FlywayUtilHibernateDAO.class);
|
||||
|
||||
@Autowired
|
||||
public FlywayUtilHibernateDAO(
|
||||
@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existeErroExecucaoScript() {
|
||||
final List<Boolean> ls = new ArrayList<Boolean>();
|
||||
|
||||
try {
|
||||
|
||||
getSession().doWork(new Work() {
|
||||
|
||||
@Override
|
||||
public void execute(Connection conn) throws SQLException {
|
||||
ResultSet rs = conn.prepareStatement("select count(*) from \"schema_version\" where \"success\"=0").executeQuery();
|
||||
if (rs.next()) {
|
||||
ls.add(rs.getInt(1) > 0);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (DataAccessResourceFailureException e) {
|
||||
log.error("", e);
|
||||
} catch (HibernateException e) {
|
||||
log.error("", e);
|
||||
} catch (IllegalStateException e) {
|
||||
log.error("", e);
|
||||
}
|
||||
|
||||
return (ls.size()>0 && ls.get(0));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
public interface FlywayUtilService {
|
||||
|
||||
public boolean existeErroExecucaoScript();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.FlywayUtilDAO;
|
||||
import com.rjconsultores.ventaboletos.service.FlywayUtilService;
|
||||
|
||||
@Service("flywayUtilService")
|
||||
public class FlywayUtilServiceImpl implements FlywayUtilService {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(FlywayUtilServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private FlywayUtilDAO flywayUtilDAO;
|
||||
|
||||
@Override
|
||||
public boolean existeErroExecucaoScript() {
|
||||
boolean existeErro = true;
|
||||
try{
|
||||
existeErro = flywayUtilDAO.existeErroExecucaoScript();
|
||||
}catch(Throwable t){
|
||||
log.error("",t);
|
||||
}
|
||||
|
||||
return existeErro;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue