Search in sources :

Example 1 with Employee

use of tutorial.entity.Employee in project stackoverflow-qa by yukihane.

the class BatchDeleteTest method testBatchDelete.

public void testBatchDelete() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        List<Employee> list = dao.selectAll();
        dao.batchDelete(list);
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction)

Example 2 with Employee

use of tutorial.entity.Employee in project stackoverflow-qa by yukihane.

the class BatchInsertTest method testBatchInsert.

public void testBatchInsert() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        Employee employee1 = new Employee();
        employee1.setName("test-1");
        employee1.setAge(30);
        employee1.setSalary(new Salary(300));
        Employee employee2 = new Employee();
        employee2.setName("test-2");
        employee2.setAge(40);
        employee2.setSalary(new Salary(500));
        dao.batchInsert(Arrays.asList(employee1, employee2));
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Salary(tutorial.domain.Salary) Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction)

Example 3 with Employee

use of tutorial.entity.Employee in project stackoverflow-qa by yukihane.

the class DeleteTest method testDeleteWithSqlFile.

public void testDeleteWithSqlFile() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        Employee employee = dao.selectById(1);
        dao.deleteWithSqlFile(employee);
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction)

Example 4 with Employee

use of tutorial.entity.Employee in project stackoverflow-qa by yukihane.

the class InsertTest method testInsertWithSqlFile.

public void testInsertWithSqlFile() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        Employee employee = new Employee();
        employee.setId(100);
        employee.setName("test");
        employee.setAge(50);
        employee.setSalary(new Salary(300));
        employee.setJobType(JobType.PRESIDENT);
        employee.setInsertTimestamp(new Timestamp(System.currentTimeMillis()));
        employee.setVersion(1);
        dao.insertWithSqlFile(employee);
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Salary(tutorial.domain.Salary) Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction) Timestamp(java.sql.Timestamp)

Example 5 with Employee

use of tutorial.entity.Employee in project stackoverflow-qa by yukihane.

the class InsertTest method testInsert.

public void testInsert() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        Employee employee = new Employee();
        employee.setName("test");
        employee.setAge(50);
        employee.setSalary(new Salary(300));
        employee.setJobType(JobType.PRESIDENT);
        dao.insert(employee);
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Salary(tutorial.domain.Salary) Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction)

Aggregations

Employee (tutorial.entity.Employee)27 LocalTransaction (org.seasar.doma.jdbc.tx.LocalTransaction)26 Salary (tutorial.domain.Salary)9 IterationContext (org.seasar.doma.jdbc.IterationContext)3 Timestamp (java.sql.Timestamp)2 SelectOptions (org.seasar.doma.jdbc.SelectOptions)2 KeepAliveLocalTransaction (org.seasar.doma.jdbc.tx.KeepAliveLocalTransaction)1