use of sqlite.feature.many2many.case7.BindAppDataSource.Transaction in project kripton by xcesco.
the class TestFeatureRuntime2 method testRuntime.
@Test
public void testRuntime() {
BindAppDataSource ds = BindAppDataSource.getInstance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
DaoCityImpl dao = daoFactory.getDaoCity();
long id1;
long id2;
City bean1 = new City();
bean1.name = "city1";
id1 = dao.insert(bean1);
City bean2 = new City();
bean2.name = "city2";
id2 = dao.insert(bean2);
long[] params = { id1, id2 };
assertTrue(dao.selectAll(params).size() == 2);
return TransactionResult.COMMIT;
}
});
}
use of sqlite.feature.many2many.case7.BindAppDataSource.Transaction in project kripton by xcesco.
the class TestFeatureRuntime3 method testRuntime.
@Test
public void testRuntime() {
BindAppDataSource ds = BindAppDataSource.getInstance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
DaoCityImpl dao = daoFactory.getDaoCity();
long id1;
long id2;
City bean1 = new City();
bean1.name = "city1";
id1 = dao.insert(bean1);
City bean2 = new City();
bean2.name = "city2";
id2 = dao.insert(bean2);
Long[] params = { id1, id2 };
assertTrue(dao.selectAll(params).size() == 2);
return TransactionResult.COMMIT;
}
});
}
use of sqlite.feature.many2many.case7.BindAppDataSource.Transaction in project kripton by xcesco.
the class TestRuntimeMany2Many7 method testMany2Many.
/**
* Test many 2 many.
*
* @throws InterruptedException
* the interrupted exception
*/
@Test
public void testMany2Many() throws InterruptedException {
BindAppDataSource ds = BindAppDataSource.getInstance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
List<City> cities = new ArrayList<City>();
List<Person> persons = new ArrayList<Person>();
CityDaoImpl cityDao = daoFactory.getCityDao();
PersonDaoImpl personDao = daoFactory.getPersonDao();
City2PersonDaoImpl m2mDao = daoFactory.getCity2PersonDao();
// insert city
for (int i = 0; i < 1; i++) {
City bean = new City();
bean.name = "city" + i;
cityDao.insert(bean);
cities.add(bean);
}
// insert person
for (int i = 0; i < 1; i++) {
Person bean = new Person();
bean.name = "person" + i;
personDao.insert(bean);
persons.add(bean);
}
{
// m2m
CityPerson bean = new CityPerson(0, cities.get(0).id, persons.get(0).id);
m2mDao.insert(bean);
}
return TransactionResult.COMMIT;
}
});
}
use of sqlite.feature.many2many.case7.BindAppDataSource.Transaction in project kripton by xcesco.
the class TestFeatureRuntime4 method testRuntime.
@Test
public void testRuntime() {
BindAppDataSource ds = BindAppDataSource.getInstance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
DaoCityImpl dao = daoFactory.getDaoCity();
long id1;
long id2;
City bean1 = new City();
bean1.name = "city1";
bean1.setDate(new java.sql.Date((new java.util.Date().getTime())));
id1 = dao.insert(bean1);
City bean2 = new City();
bean2.name = "city2";
bean2.setDate(new java.sql.Date((new java.util.Date().getTime())));
id2 = dao.insert(bean2);
java.sql.Date[] params = { new java.sql.Date((new java.util.Date().getTime())) };
assertTrue(dao.selectAll(params).size() == 2);
return TransactionResult.COMMIT;
}
});
}
use of sqlite.feature.many2many.case7.BindAppDataSource.Transaction in project kripton by xcesco.
the class TestFeatureRuntime5 method testRuntime.
@Test
public void testRuntime() {
BindAppDataSource ds = BindAppDataSource.getInstance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, 2000);
c.set(Calendar.MONTH, 5);
c.set(Calendar.DAY_OF_MONTH, 10);
DaoCityImpl dao = daoFactory.getDaoCity();
java.sql.Date date = new java.sql.Date(c.getTime().getTime());
City bean1 = new City();
bean1.name = "city1";
bean1.setDate(date);
dao.insert(bean1);
City bean2 = new City();
bean2.name = "city2";
bean2.setDate(date);
dao.insert(bean2);
java.sql.Date[] params = { new java.sql.Date(date.getTime()) };
assertTrue(dao.selectAll(params).size() == 2);
return TransactionResult.COMMIT;
}
});
}
Aggregations