Package com.mysema.query.sql.domain

Examples of com.mysema.query.sql.domain.Employee


    protected Employee employee;
   
    @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);
View Full Code Here


    private final QEmployee e = new QEmployee("e");
   
    @Test
    public void Direct_to_Managed_type() {
        FactoryExpression<Employee> expr = new QBean<Employee>(Employee.class, e.superiorId);       
        Employee e = expr.newInstance(3);
        assertEquals(Integer.valueOf(3), e.getSuperiorId());
    }
View Full Code Here

    }
   
    @Test
    public void Direct_to_Custom_type() {
        FactoryExpression<Employee> expr = new QBean<Employee>(Employee.class, e.firstname, e.lastname);       
        Employee e = expr.newInstance("John","Smith");
        assertEquals("John", e.getFirstname());
        assertEquals("Smith", e.getLastname());
    }
View Full Code Here

    }
   
    @Test
    public void Alias_to_Managed_type() {
        FactoryExpression<Employee> expr = new QBean<Employee>(Employee.class, e.superiorId.as("id"));       
        Employee e = expr.newInstance(3);
        assertEquals(3, e.getId().intValue());
    }
View Full Code Here

    }
   
    @Test
    public void Alias_to_Custom_type() {
        FactoryExpression<Employee> expr = new QBean<Employee>(Employee.class, e.firstname.as("lastname"), e.lastname.as("firstname"));       
        Employee e = expr.newInstance("John","Smith");
        assertEquals("Smith", e.getFirstname());
        assertEquals("John", e.getLastname());
    }
View Full Code Here

    }

    @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).uniqueResult(e);
        assertEquals("John", smith.getFirstname());

        // Delete (no changes needed)
        assertEquals(1l, delete(e).where(e.id.eq(employee.getId())).execute());
    }
View Full Code Here

        assertEquals(1l, delete(e).where(e.id.eq(employee.getId())).execute());
    }

    @Test
    public void Populate_With_BeanMapper() {
        Employee employee = new Employee();
        employee.setFirstname("John");
        insert(e).populate(employee, new BeanMapper()).execute();
    }
View Full Code Here

    }

    @Test
    public void CustomProjection() {
        // 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);
View Full Code Here

TOP

Related Classes of com.mysema.query.sql.domain.Employee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.