Search in sources :

Example 1 with Employee

use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.

the class BeanPopulationBase method populate_with_beanMapper.

@Test
public void populate_with_beanMapper() {
    Employee employee = new Employee();
    employee.setFirstname("John");
    insert(e).populate(employee, new BeanMapper()).execute();
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) BeanMapper(com.querydsl.sql.dml.BeanMapper) Test(org.junit.Test)

Example 2 with Employee

use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.

the class SubqueriesBase method keys.

@Test
@ExcludeIn({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, SQLITE, SQLSERVER })
public void keys() {
    QEmployee employee2 = new QEmployee("employee2");
    ForeignKey<Employee> nameKey1 = new ForeignKey<Employee>(employee, ImmutableList.of(employee.firstname, employee.lastname), ImmutableList.of("a", "b"));
    ForeignKey<Employee> nameKey2 = new ForeignKey<Employee>(employee, ImmutableList.of(employee.firstname, employee.lastname), ImmutableList.of("a", "b"));
    query().from(employee).where(nameKey1.in(query().from(employee2).select(nameKey2.getProjection()))).select(employee.id).fetch();
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 3 with Employee

use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.

the class QBeanTest method alias_to_managed_type.

@Test
public void alias_to_managed_type() {
    FactoryExpression<Employee> expr = Projections.bean(Employee.class, e.superiorId.as("id"));
    Employee e = expr.newInstance(3);
    assertEquals(3, e.getId().intValue());
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 4 with Employee

use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.

the class QBeanTest method alias_to_custom_type.

@Test
public void alias_to_custom_type() {
    FactoryExpression<Employee> expr = Projections.bean(Employee.class, e.firstname.as("lastname"), e.lastname.as("firstname"));
    Employee e = expr.newInstance("John", "Smith");
    assertEquals("Smith", e.getFirstname());
    assertEquals("John", e.getLastname());
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 5 with Employee

use of com.querydsl.sql.domain.Employee in project querydsl by querydsl.

the class UnionBase method union_factoryExpression.

@SuppressWarnings("unchecked")
@Test
public void union_factoryExpression() {
    SubQueryExpression<Employee> sq1 = query().from(employee).select(Projections.constructor(Employee.class, employee.id));
    SubQueryExpression<Employee> sq2 = query().from(employee).select(Projections.constructor(Employee.class, employee.id));
    List<Employee> employees = query().union(sq1, sq2).list();
    for (Employee employee : employees) {
        assertNotNull(employee);
    }
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Aggregations

Employee (com.querydsl.sql.domain.Employee)11 QEmployee (com.querydsl.sql.domain.QEmployee)10 Test (org.junit.Test)10 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)1 BeanMapper (com.querydsl.sql.dml.BeanMapper)1 BigDecimal (java.math.BigDecimal)1 Date (java.sql.Date)1 Time (java.sql.Time)1 Before (org.junit.Before)1