if (null == datasource) {
OqlBuilder<DatasourceBean> builder = OqlBuilder.from(DatasourceBean.class, "ds");
builder.where("ds.id=:id", id);
List<DatasourceBean> beans = entityDao.search(builder);
if (!beans.isEmpty()) {
DatasourceBean bean = beans.get(0);
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setUrl(bean.getUrl());
ds.setUsername(bean.getUsername());
ds.setPassword(bean.getPassword());
ds.setDriverClassName(bean.getDriverClassName());
Properties properties = new Properties();
for (DatasourcePropertyBean propertyBean : bean.getProperties()) {
properties.put(propertyBean.getName(), propertyBean.getValue());
}
ds.setConnectionProperties(properties);
datasource = ds;
}