Package org.hibernate.test.sql.hand

Examples of org.hibernate.test.sql.hand.Organization


  }

  public void testBadInsertionFails() {
    Session session = openSession();
    session.beginTransaction();
    Organization org = new Organization( "hola!" );
    try {
      session.save( org );
      session.delete( org );
      fail( "expecting bad custom insert statement to fail" );
    }
View Full Code Here


    s.beginTransaction();

    sfi().getStatistics().clear();

    // create an Organization...
    Organization jboss = new Organization( "JBoss" );
    s.persist( jboss );

    // now query on Employment, this should not cause an auto-flush
    s.createSQLQuery( getEmploymentSQL() ).list();
    assertEquals( 0, sfi().getStatistics().getEntityInsertCount() );
View Full Code Here

  }

  public void testSQLQueryInterface() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Organization ifa = new Organization("IFA");
    Organization jboss = new Organization("JBoss");
    Person gavin = new Person("Gavin");
    Employment emp = new Employment(gavin, jboss, "AU");

    s.persist(ifa);
    s.persist(jboss);
View Full Code Here

  }

  public void testResultSetMappingDefinition() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Organization ifa = new Organization("IFA");
    Organization jboss = new Organization("JBoss");
    Person gavin = new Person("Gavin");
    Employment emp = new Employment(gavin, jboss, "AU");

    s.persist(ifa);
    s.persist(jboss);
View Full Code Here

  public void testScalarValues() throws Exception {
    Session s = openSession();
    Transaction t = s.beginTransaction();

    Organization ifa = new Organization( "IFA" );
    Organization jboss = new Organization( "JBoss" );

    Serializable idIfa = s.save( ifa );
    Serializable idJBoss = s.save( jboss );

    s.flush();
View Full Code Here

  }

  public void testMappedAliasStrategy() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Organization ifa = new Organization("IFA");
    Organization jboss = new Organization("JBoss");
    Person gavin = new Person("Gavin");
    Employment emp = new Employment(gavin, jboss, "AU");
    Serializable orgId = s.save(jboss);
    Serializable orgId2 = s.save(ifa);
    s.save(gavin);
View Full Code Here

  }

  public void testAutoDetectAliasing() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Organization ifa = new Organization("IFA");
    Organization jboss = new Organization("JBoss");
    Person gavin = new Person("Gavin");
    Employment emp = new Employment(gavin, jboss, "AU");
    Serializable orgId = s.save(jboss);
    Serializable orgId2 = s.save(ifa);
    s.save(gavin);
    s.save(emp);
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    List list = s.createSQLQuery( getEmploymentSQL() )
        .addEntity( Employment.class.getName() )
        .list();
    assertEquals( 1,list.size() );

    Employment emp2 = (Employment) list.get(0);
    assertEquals(emp2.getEmploymentId(), emp.getEmploymentId() );
    assertEquals(emp2.getStartDate().getDate(), emp.getStartDate().getDate() );
    assertEquals(emp2.getEndDate(), emp.getEndDate() );

    s.clear();

    list = s.createSQLQuery( getEmploymentSQL() )
    .addEntity( Employment.class.getName() )
    .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
    .list();
    assertEquals( 1,list.size() );
    Map m = (Map) list.get(0);
    assertTrue(m.containsKey("Employment"));
    assertEquals(1,m.size());

    list = s.createSQLQuery(getEmploymentSQL()).list();
    assertEquals(1, list.size());
    Object[] o = (Object[]) list.get(0);
    assertEquals(8, o.length);

    list = s.createSQLQuery( getEmploymentSQL() ).setResultTransformer( new UpperCasedAliasToEntityMapResultTransformer() ).list();
    assertEquals(1, list.size());
    m = (Map) list.get(0);
    assertTrue(m.containsKey("EMPID"));
    assertTrue(m.containsKey("VALUE"));
    assertTrue(m.containsKey("ENDDATE"));
    assertEquals(8, m.size());

    list = s.createSQLQuery( getEmploymentSQLMixedScalarEntity() ).addScalar( "employerid" ).addEntity( Employment.class ).list();
    assertEquals(1, list.size());
    o = (Object[]) list.get(0);
    assertEquals(2, o.length);
    assertClassAssignability( o[0].getClass(), Number.class);
    assertClassAssignability( o[1].getClass(), Employment.class);



    Query queryWithCollection = s.getNamedQuery("organizationEmploymentsExplicitAliases");
    queryWithCollection.setLong("id",  jboss.getId() );
    list = queryWithCollection.list();
    assertEquals(list.size(),1);

    s.clear();
View Full Code Here

  }

  public void testBadInsertionFails() {
    Session session = openSession();
    session.beginTransaction();
    Organization org = new Organization( "hola!" );
    try {
      session.save( org );
      session.delete( org );
      fail( "expecting bad custom insert statement to fail" );
    }
View Full Code Here

    s.beginTransaction();

    sfi().getStatistics().clear();

    // create an Organization...
    Organization jboss = new Organization( "JBoss" );
    s.persist( jboss );

    // now query on Employment, this should not cause an auto-flush
    s.createSQLQuery( getEmploymentSQL() ).list();
    assertEquals( 0, sfi().getStatistics().getEntityInsertCount() );
View Full Code Here

  }

  public void testSQLQueryInterface() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Organization ifa = new Organization("IFA");
    Organization jboss = new Organization("JBoss");
    Person gavin = new Person("Gavin");
    Employment emp = new Employment(gavin, jboss, "AU");

    s.persist(ifa);
    s.persist(jboss);
View Full Code Here

TOP

Related Classes of org.hibernate.test.sql.hand.Organization

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.