Package org.hibernate

Examples of org.hibernate.Session.save()


  public void testBidirectionalManyToOneRemoval() throws Exception {
    final Session session = openSession();
    Transaction transaction = session.beginTransaction();
    SalesForce force = new SalesForce( "red_hat" );
    force.setCorporation( "Red Hat" );
    session.save( force );
    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
    session.save( eric );
View Full Code Here


    session.save( force );
    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
    session.save( eric );
    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
View Full Code Here

    session.save( eric );
    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
    transaction.commit();
    session.clear();

    // removing one sales guy, leaving the other in place
    transaction = session.beginTransaction();
View Full Code Here

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

    SalesForce force = new SalesForce( "red_hat" );
    force.setCorporation( "Red Hat" );
    session.save( force );

    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
View Full Code Here

    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
    session.save( eric );

    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
View Full Code Here

    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );

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

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

  public void testBidirectionalManyToOneRegular() throws Exception {
    final Session session = openSession();
    Transaction transaction = session.beginTransaction();
    SalesForce force = new SalesForce( "sales_force" );
    force.setCorporation( "Red Hat" );
    session.save( force );
    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
    session.save( eric );
View Full Code Here

    session.save( force );
    SalesGuy eric = new SalesGuy( "eric" );
    eric.setName( "Eric" );
    eric.setSalesForce( force );
    force.getSalesGuys().add( eric );
    session.save( eric );
    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
View Full Code Here

    session.save( eric );
    SalesGuy simon = new SalesGuy( "simon" );
    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    force = (SalesForce) session.get( SalesForce.class, force.getId() );
View Full Code Here

      post.setCreateDt(updateDt);
      post.setUpdateDt(updateDt);

      LOG.debug("The new post is : " + post);

      int id = (Integer) session.save(post);

      LOG.debug("The OBJ_ID of the new post inserted is : " + id);
  }
  catch (Exception e) {
      LOG.error("Error occured while saving the new post: " + e);
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.