Package org.hibernate.ejb.metamodel

Examples of org.hibernate.ejb.metamodel.Customer


*/
public class TupleCriteriaTest extends AbstractMetamodelSpecificTest {
  public void testArray() {
    EntityManager em = factory.createEntityManager();
    em.getTransaction().begin();
    Customer c1 = new Customer();
    c1.setId( "c1" );
    c1.setAge( 18 );
    c1.setName( "Bob" );
    em.persist( c1 );
    em.getTransaction().commit();
    em.close();

    em = factory.createEntityManager();
    em.getTransaction().begin();
    final CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Object[]> q = cb.createQuery(Object[].class);
    Root<Customer> c = q.from(Customer.class);
    q.select( cb.array( c.get(Customer_.name), c.get(Customer_.age) ) );
    List<Object[]> result = em.createQuery(q).getResultList();
    assertEquals( 1, result.size() );
    assertEquals( c1.getName(), result.get( 0 )[0] );
    assertEquals( c1.getAge(), result.get( 0 )[1] );
    em.getTransaction().commit();
    em.close();

    em = factory.createEntityManager();
    em.getTransaction().begin();
View Full Code Here


  public void testTuple() {
    EntityManager em = factory.createEntityManager();

    em.getTransaction().begin();
    Customer c1 = new Customer();
    c1.setId( "c1" );
    c1.setAge( 18 );
    c1.setName( "Bob" );
    em.persist( c1 );
    em.getTransaction().commit();
    em.close();

    em = factory.createEntityManager();
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.metamodel.Customer

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.