Package org.hibernate

Examples of org.hibernate.Session.beginTransaction()


      @Override
      public String call() throws Exception {
        Session session = openSession();

        Transaction transaction = session.beginTransaction();
        final Novel novel = (Novel) session.get( Novel.class, "novel-1" );
        session.delete( novel );
        transaction.commit();

        return novel.get_rev();
View Full Code Here


      @Override
      public String call() throws Exception {
        Session session = openSession();

        Transaction transaction = session.beginTransaction();
        final Animal animal = (Animal) session.get( Animal.class, "animal-1" );
        animal.setName( "Xavier" );
        transaction.commit();

        return animal.getRevision();
View Full Code Here

      public String call() throws Exception {
        Session session = openSession();

        Animal berta = createAndPersistAnotherAnimal( session );

        Transaction transaction = session.beginTransaction();
        final Zoo zoo = (Zoo) session.get( Zoo.class, "zoo-1" );
        zoo.getAnimals().add( berta );
        transaction.commit();

        return zoo.getRevision();
View Full Code Here

    return Executors.newSingleThreadExecutor().submit( new Callable<String>() {

      @Override
      public String call() throws Exception {
        Session session = openSession();
        Transaction transaction = session.beginTransaction();

        final Zoo zoo = (Zoo) session.get( Zoo.class, "zoo-1" );
        zoo.setName( "Hilwema" );

        transaction.commit();
View Full Code Here

      @Override
      public String call() throws Exception {
        Session session = openSession();

        Transaction transaction = session.beginTransaction();
        final Project project = (Project) session.get( Project.class, "project-1" );

        Contributor sanne = new Contributor();
        sanne.setId( "contributor-2" );
        sanne.setName( "Sanne" );
View Full Code Here

  private final OscarWildePoem ballade = new OscarWildePoem( 3L, "Ballade De Marguerite", "Oscar Wilde", new GregorianCalendar( 1881, 3, 1 ).getTime() );

  @Before
  public void init() {
    Session session = openSession();
    Transaction transaction = session.beginTransaction();
    session.persist( portia );
    session.persist( athanasia );
    session.persist( ballade );
    transaction.commit();
    session.clear();
View Full Code Here

  }

  @After
  public void tearDown() {
    Session session = openSession();
    Transaction tx = session.beginTransaction();
    delete( session, portia );
    delete( session, athanasia );
    delete( session, ballade);
    tx.commit();
    session.clear();
View Full Code Here

  }

  @Test
  public void testListMultipleResultQueryWithFirstResultAndMaxRows() throws Exception {
    Session session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { author:'Oscar Wilde' } ) RETURN n ORDER BY n.name DESC";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = session.createSQLQuery( nativeQuery )
        .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )
View Full Code Here

  }

  @Test
  public void databaseAccessWithCredentialsShouldSucceed() {
    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    Flower flower = new Flower();
    flower.setId( "1" );
    flower.setName( "Caltha palustris" );
View Full Code Here

    session.persist( flower );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();

    Flower loadedFlower = (Flower) session.get( Flower.class, flower.getId() );
    assertNotNull( loadedFlower );
    assertEquals( flower.getName(), loadedFlower.getName() );
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.