Package org.hibernate

Examples of org.hibernate.Session.load()


   * @throws IOException
   */
  public static void forceDelete(int log_id) throws Exception{
    Session ssn = getSession();
    try{
      DiaryBean log = (DiaryBean)ssn.load(DiaryBean.class, new Integer(log_id));
      beginTransaction();
      //����������ռ����Ӧ�ķ����ռ�����һ
      if(log.getStatus()==DiaryBean.STATUS_NORMAL){
        log.getCatalog().incArticleCount(-1);
      }
View Full Code Here


   
    // --- update
    session = handler.getSession();
    try {
      tx = session.beginTransaction();
      Category theCat = (Category) session.load(Category.class, catId);
      theCat.setTitle("Another category title");
      tx.commit();
      System.out.println("Updated category title for id: " + catId);
    } catch (HibernateException he) {
      if (tx != null) tx.rollback();
View Full Code Here

  private void verifyChannel(String label, long chan_id) {
    try {
      Session session = handler.getSession();
      log.info(label + chan_id);
      Channel aChan = (Channel) session.load(Channel.class, new Long(chan_id));
      assertEquals((long) chan_id, aChan.getId());
      assertNotNull(aChan.getTitle());
      logChannel(aChan);
      session.flush();
      session.close();
View Full Code Here

            String state, String zipCode, String Country) {

        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        Address a = (Address) sess.load(Address.class, id);

        a.setName(name);
        a.setOrganization(organization);
        a.setPhone(phone);
        a.setAddress1(address1);
View Full Code Here

        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        // Get the employee and associated user
        Employee emp = (Employee) sess.load(Employee.class, id);
        User u = emp.getUser();

        // Set user data
        u.setUsername(username);
        u.setFirstName(firstname);
View Full Code Here

    public static void deleteEmployee(int id) {
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        Employee emp = (Employee) sess.load(Employee.class, id);
        sess.delete(emp);

        sess.getTransaction().commit();
    }
}
View Full Code Here

        // Otherwise, really go out and check our permissions.
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        // Use a current instance of our user
        User u = (User) sess.load(User.class, getId());

        // Check user permissions
        for (Object p : u.getPermissions()) {
            if (((Permission) p).getCodeName().equals(perm)) {
                sess.getTransaction().commit();
View Full Code Here

    }
    assertFalse( "flake not removed", present );
    for ( SnowFlake current : cloud.getProducedSnowFlakes() ) {
      session.delete( current );
    }
    session.delete( session.load( SnowFlake.class, removedSf.getId() ) );
    cloud.getProducedSnowFlakes().clear();
    transaction.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 1 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( 0 );
View Full Code Here

        .isNull();
    assertThat( father.getOrderedChildren().get( 2 ).getName() )
        .as( "Leia should be third" )
        .isEqualTo( leia.getName() );
    session.delete( father );
    session.delete( session.load( Child.class, luke.getId() ) );
    session.delete( session.load( Child.class, leia.getId() ) );
    tx.commit();

    session.close();
View Full Code Here

    assertThat( father.getOrderedChildren().get( 2 ).getName() )
        .as( "Leia should be third" )
        .isEqualTo( leia.getName() );
    session.delete( father );
    session.delete( session.load( Child.class, luke.getId() ) );
    session.delete( session.load( Child.class, leia.getId() ) );
    tx.commit();

    session.close();

    checkCleanCache();
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.