Package org.hibernate

Examples of org.hibernate.StatelessSession.createQuery()


            }

            protected void renderResponse() throws Exception {
                StatelessSession ss = getStatelessSession();
                List<String> uploads =
                        ss.createQuery("select wu.filename from WikiUpload wu where wu.parent.id = :parent order by wu.createdOn desc ")
                        .setParameter("parent" , 2l).list();

                assert uploads.size() == 3;
                assert uploads.get(0).equals("testupload2.zip");
            }
View Full Code Here


   
    Document doc2 = (Document) ss.get(Document.class.getName(), "Blahs");
    assertEquals("Blahs", doc2.getName());
    assertEquals(doc.getText(), doc2.getText());
       
    doc2 = (Document) ss.createQuery("from Document where text is not null").uniqueResult();
    assertEquals("Blahs", doc2.getName());
    assertEquals(doc.getText(), doc2.getText());
   
    ScrollableResults sr = ss.createQuery("from Document where text is not null")
      .scroll(ScrollMode.FORWARD_ONLY);
View Full Code Here

       
    doc2 = (Document) ss.createQuery("from Document where text is not null").uniqueResult();
    assertEquals("Blahs", doc2.getName());
    assertEquals(doc.getText(), doc2.getText());
   
    ScrollableResults sr = ss.createQuery("from Document where text is not null")
      .scroll(ScrollMode.FORWARD_ONLY);
    sr.next();
    doc2 = (Document) sr.get(0);
    sr.close();
    assertEquals("Blahs", doc2.getName());
View Full Code Here

    paper.setColor( "White" );
    ss.insert(paper);
    tx.commit();

    tx = ss.beginTransaction();
    int count = ss.createQuery( "update Document set name = :newName where name = :oldName" )
        .setString( "newName", "Foos" )
        .setString( "oldName", "Blahs" )
        .executeUpdate();
    assertEquals( "hql-update on stateless session", 1, count );
    count = ss.createQuery( "update Paper set color = :newColor" )
View Full Code Here

    int count = ss.createQuery( "update Document set name = :newName where name = :oldName" )
        .setString( "newName", "Foos" )
        .setString( "oldName", "Blahs" )
        .executeUpdate();
    assertEquals( "hql-update on stateless session", 1, count );
    count = ss.createQuery( "update Paper set color = :newColor" )
        .setString( "newColor", "Goldenrod" )
        .executeUpdate();
    assertEquals( "hql-update on stateless session", 1, count );
    tx.commit();
View Full Code Here

        .executeUpdate();
    assertEquals( "hql-update on stateless session", 1, count );
    tx.commit();

    tx = ss.beginTransaction();
    count = ss.createQuery( "delete Document" ).executeUpdate();
    assertEquals( "hql-delete on stateless session", 1, count );
    count = ss.createQuery( "delete Paper" ).executeUpdate();
    assertEquals( "hql-delete on stateless session", 1, count );
    tx.commit();
    ss.close();
View Full Code Here

    tx.commit();

    tx = ss.beginTransaction();
    count = ss.createQuery( "delete Document" ).executeUpdate();
    assertEquals( "hql-delete on stateless session", 1, count );
    count = ss.createQuery( "delete Paper" ).executeUpdate();
    assertEquals( "hql-delete on stateless session", 1, count );
    tx.commit();
    ss.close();
  }
View Full Code Here

    s.getTransaction().commit();
    s.close();

    StatelessSession ss = sfi().openStatelessSession();
    ss.beginTransaction();
    Task taskRef = ( Task ) ss.createQuery( "from Task t join fetch t.resource join fetch t.user" ).uniqueResult();
    assertTrue( taskRef != null );
    assertTrue( Hibernate.isInitialized( taskRef ) );
    assertTrue( Hibernate.isInitialized( taskRef.getUser() ) );
    assertTrue( Hibernate.isInitialized( taskRef.getResource() ) );
    assertFalse( Hibernate.isInitialized( taskRef.getResource().getOwner() ) );
View Full Code Here

  public void testHQL() {
    TestData testData=new TestData();
    testData.createData();
    StatelessSession s = getSessions().openStatelessSession();
    assertEquals( 1, s.createQuery( "from Contact c join fetch c.org join fetch c.org.country" )
        .list().size() );
    s.close();
    testData.cleanData();
  }
  private class TestData{
View Full Code Here

  public void testHQL() {
    TestData testData=new TestData();
    testData.createData();
    StatelessSession s = getSessions().openStatelessSession();
    assertEquals( 1, s.createQuery( "from Contact c join fetch c.org join fetch c.org.country" )
        .list().size() );
    s.close();
    testData.cleanData();
  }
  private class TestData{
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.