Package org.hibernate

Examples of org.hibernate.Session.merge()


  public Object saveOrUpdate(Object feature) throws LayerException {
    // force the srid value
    enforceSrid(feature);
    Session session = getSessionFactory().getCurrentSession();
    // using merge to allow detached objects, although Geomajas avoids them
    return session.merge(feature);
  }

  public void delete(String featureId) throws LayerException {
    Session session = getSessionFactory().getCurrentSession();
    session.delete(getFeature(featureId));
View Full Code Here


    final Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when updating the golf player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.2 );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect one (batched) insert with the configured write concern
View Full Code Here

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when associating the golf course to the player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ) );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect one update using the configured write concern for adding the row
View Full Code Here

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when merging the player with two associated courses
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ), new GolfCourse( 2L, "Ant Sandrews" ) );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect updates to the player document using the configured write concern
View Full Code Here

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when merging the player with two associated courses
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ), new GolfCourse( 2L, "Ant Sandrews" ) );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect one update to the association collection
View Full Code Here

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when removing the association
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1 );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect one call to update using the configured write concern
View Full Code Here

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when removing the association
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1 );
    session.merge( ben );

    transaction.commit();
    session.close();

    // then expect one call to remove with the configured write concern
View Full Code Here

    session.clear();

    transaction = session.beginTransaction();
    loadedHyp.setDescription( "P != NP");
    session.merge( loadedHyp );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
View Full Code Here

   }

   public Object save(Object obj) throws Exception
   {
      Session session = openSession();
      session.merge(obj);
      session.flush();
      return obj;
   }

   public Object remove(Object obj) throws Exception
View Full Code Here

                    .list();
            if (workspaces.size() == 0) {
                throw new LumifyException("Could not find workspace with id: " + workspaceId);
            }
            sqlUser.setCurrentWorkspace(workspaces.get(0));
            session.merge(sqlUser);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
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.