CommonDAO implements ICommonDAO { @Override public void execSQLScript(String sql) { EntityManager em = emf.createEntityManager(); try{ em.createNativeQuery(sql); } catch (PersistenceException e) { logger.error("Class CommonDAO is method findByNativeSQL(String sql) error!",e); } finally{ em.close(); } }  @SuppressWarnings("unchecked") @Override List<T> findByNativeSQL(String sql, Object[] params); @SuppressWarnings("unchecked") @Override List<T> findByNativeSQL(String sql, Map<String, Object> params); @Override void execSQLScript(String sql);  }
@Test public void testExecSQLScript() { String sql = "CREATE TABLE `base_url_info_test` ( "+ "`id` int(11) NOT NULL AUTO_INCREMENT,"+ "`url` varchar(255) DEFAULT NULL,"+ "`url_detail_id` int(11) DEFAULT NULL,"+ "`search_type` int(11) DEFAULT NULL COMMENT '1唯一，2类',"+ "`priority` int(11) DEFAULT '0' COMMENT '优先级随数字增大',"+ "PRIMARY KEY (`id`)"+ ") ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8;"; commonDAO.execSQLScript(sql); }