use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.
the class AbstractMapperTest method setUp.
@Before
public void setUp() {
employee = new Employee();
employee.setDatefield(new Date(0));
employee.setFirstname("A");
employee.setLastname("B");
employee.setSalary(new BigDecimal(1.0));
employee.setSuperiorId(2);
employee.setTimefield(new Time(0));
}
use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.
the class QBeanTest method direct_to_custom_type.
@Test
public void direct_to_custom_type() {
FactoryExpression<Employee> expr = Projections.bean(Employee.class, e.firstname, e.lastname);
Employee e = expr.newInstance("John", "Smith");
assertEquals("John", e.getFirstname());
assertEquals("Smith", e.getLastname());
}
use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.
the class QBeanTest method direct_to_managed_type.
@Test
public void direct_to_managed_type() {
FactoryExpression<Employee> expr = Projections.bean(Employee.class, e.superiorId);
Employee e = expr.newInstance(3);
assertEquals(Integer.valueOf(3), e.getSuperiorId());
}
use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.
the class BeanPopulationBase method custom_projection.
@Test
public void custom_projection() {
// Insert
Employee employee = new Employee();
employee.setFirstname("John");
Integer id = insert(e).populate(employee).executeWithKey(e.id);
employee.setId(id);
// Update
employee.setLastname("S");
assertEquals(1L, update(e).populate(employee).where(e.id.eq(employee.getId())).execute());
// Query
Employee smith = extQuery().from(e).where(e.lastname.eq("S")).limit(1).uniqueResult(Employee.class, e.lastname, e.firstname);
assertEquals("John", smith.getFirstname());
assertEquals("S", smith.getLastname());
// Query with alias
smith = extQuery().from(e).where(e.lastname.eq("S")).limit(1).uniqueResult(Employee.class, e.lastname.as("lastname"), e.firstname.as("firstname"));
assertEquals("John", smith.getFirstname());
assertEquals("S", smith.getLastname());
// Query into custom type
OtherEmployee other = extQuery().from(e).where(e.lastname.eq("S")).limit(1).uniqueResult(OtherEmployee.class, e.lastname, e.firstname);
assertEquals("John", other.getFirstname());
assertEquals("S", other.getLastname());
// Delete (no changes needed)
assertEquals(1L, delete(e).where(e.id.eq(employee.getId())).execute());
}
use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.
the class BeanPopulationBase method insert_update_query_and_delete.
@Test
public void insert_update_query_and_delete() {
// Insert
Employee employee = new Employee();
employee.setFirstname("John");
Integer id = insert(e).populate(employee).executeWithKey(e.id);
assertNotNull(id);
employee.setId(id);
// Update
employee.setLastname("S");
assertEquals(1L, update(e).populate(employee).where(e.id.eq(employee.getId())).execute());
// Query
Employee smith = query().from(e).where(e.lastname.eq("S")).limit(1).select(e).fetchFirst();
assertEquals("John", smith.getFirstname());
// Delete (no changes needed)
assertEquals(1L, delete(e).where(e.id.eq(employee.getId())).execute());
}
Aggregations