import org.hibernate.cfg.Configuration;
}
if (sessionFactory == null)
initSessionFactory();
return sessionFactory;
}
try {
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.xh.hibernate.vo.Test;
super(name);
}
}
}
Transaction tx = null;
Test test = null;
session = HibernateSessionFactory.getInstance().getCurrentSession();
tx = session.beginTransaction();
test.setFirstname("mao");
test.setLastname("mao");
session.save(test);
he.printStackTrace();
if (tx != null && tx.isActive())
tx.rollback();
}
}
Transaction tx = null;
List list = null;
Test test = null;
session = HibernateSessionFactory.getInstance().getCurrentSession();
tx = session.beginTransaction();
test = (Test) iterator.next();
System.out.println("firstname: " + test.getFirstname());
}
tx.commit();
} catch (HibernateException he) {
he.printStackTrace();
if (tx != null && tx.isActive())
tx.rollback();
}
}
00:30:29,671 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
00:30:29,671 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
00:30:29,687 DEBUG SessionImpl:417 - after transaction completion
00:30:29,687 DEBUG SessionImpl:348 - automatically closing session
00:30:29,687 DEBUG SessionImpl:268 - closing session
00:30:29,687 DEBUG ConnectionManager:369 - connection already null in cleanup : no action