当前位置: 首页>>代码示例>>Java>>正文


Java SessionFactory.close方法代码示例

本文整理汇总了Java中org.hibernate.SessionFactory.close方法的典型用法代码示例。如果您正苦于以下问题:Java SessionFactory.close方法的具体用法?Java SessionFactory.close怎么用?Java SessionFactory.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.SessionFactory的用法示例。


在下文中一共展示了SessionFactory.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hibernate_with_active_span_only

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void hibernate_with_active_span_only() {
  SessionFactory sessionFactory = createSessionFactory(true);
  Session session = sessionFactory.openSession();

  Employee employee = new Employee();
  session.beginTransaction();
  session.save(employee);
  session.getTransaction().commit();
  session.close();
  sessionFactory.close();

  assertNotNull(employee.id);

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(0, finishedSpans.size());

  assertNull(mockTracer.activeSpan());
}
 
开发者ID:opentracing-contrib,项目名称:java-jdbc,代码行数:20,代码来源:HibernateTest.java

示例2: hibernate

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void hibernate() throws InterruptedException {
  SessionFactory sessionFactory = createSessionFactory("");
  Session session = sessionFactory.openSession();

  Employee employee = new Employee();
  session.beginTransaction();
  session.save(employee);
  session.getTransaction().commit();
  session.close();
  sessionFactory.close();

  assertNotNull(employee.id);

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(8, finishedSpans.size());
  checkTags(finishedSpans, "myservice", "jdbc:hsqldb:mem:hibernate");
  assertNull(mockTracer.scopeManager().active());
}
 
开发者ID:opentracing-contrib,项目名称:java-p6spy,代码行数:20,代码来源:HibernateTest.java

示例3: withPeerNameInUrl

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void withPeerNameInUrl() throws InterruptedException {
  SessionFactory sessionFactory = createSessionFactory(";tracingPeerService=inurl");
  Session session = sessionFactory.openSession();

  Employee employee = new Employee();
  session.beginTransaction();
  session.save(employee);
  session.getTransaction().commit();
  session.close();
  sessionFactory.close();

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(8, finishedSpans.size());

  checkTags(finishedSpans, "inurl", "jdbc:hsqldb:mem:hibernate;tracingPeerService=inurl");

  assertNull(mockTracer.scopeManager().active());
}
 
开发者ID:opentracing-contrib,项目名称:java-p6spy,代码行数:20,代码来源:HibernateTest.java

示例4: withActiveSpanOnlyNoParent

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void withActiveSpanOnlyNoParent() throws InterruptedException {
  SessionFactory sessionFactory = createSessionFactory(";traceWithActiveSpanOnly=true");
  Session session = sessionFactory.openSession();

  Employee employee = new Employee();
  session.beginTransaction();
  session.save(employee);
  session.getTransaction().commit();
  session.close();
  sessionFactory.close();

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(0, finishedSpans.size());

  assertNull(mockTracer.scopeManager().active());
}
 
开发者ID:opentracing-contrib,项目名称:java-p6spy,代码行数:18,代码来源:HibernateTest.java

示例5: withActiveSpanOnlyWithParent

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void withActiveSpanOnlyWithParent() throws InterruptedException {
  try (Scope activeSpan = mockTracer.buildSpan("parent").startActive(true)) {
    SessionFactory sessionFactory = createSessionFactory(";traceWithActiveSpanOnly=true");
    Session session = sessionFactory.openSession();

    Employee employee = new Employee();
    session.beginTransaction();
    session.save(employee);
    session.getTransaction().commit();
    session.close();
    sessionFactory.close();
  }

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(9, finishedSpans.size());
  checkSameTrace(finishedSpans);

  assertNull(mockTracer.scopeManager().active());

}
 
开发者ID:opentracing-contrib,项目名称:java-p6spy,代码行数:22,代码来源:HibernateTest.java

示例6: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
	Configuration cfg=null;
	SessionFactory factory=null;
	Session ses=null;
	 Transaction tx=null;
			cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml");
			factory=cfg.buildSessionFactory();
		ses=factory.openSession();
	
		tx=ses.beginTransaction();
		 String hql="delete from bigbazarModel where bazarid=:id";
		 Query q=ses.createQuery(hql);
		 		q.setParameter("id", 1003);
		 			int c=q.executeUpdate();
		 			//int count=Integer.parseUnsignedInt(c);
		 			tx.commit();
		 			System.out.println("\t\t"+c+" rows Deleted");
		 		
		 			factory.close();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_UniqueResult_ExecuteUpdate_CopyData_Delete_Update,代码行数:22,代码来源:delete_HQL.java

示例7: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
	Configuration cfg=null;
	SessionFactory factory=null;
	Session ses=null;
	Transaction tx=null;
			cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml");
			factory=cfg.buildSessionFactory();
		ses=factory.openSession();
	
		 String hql="select item_name from bigbazarModel where bazarid=:id";
		 Query q=ses.createQuery(hql);
		 		q.setParameter("id", 1001);
		 			String s=(String) q.uniqueResult();
		 			System.out.println("\t\t"+s);
		 			
		 			factory.close();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_UniqueResult_ExecuteUpdate_CopyData_Delete_Update,代码行数:19,代码来源:TestClass.java

示例8: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
	Configuration cfg=null;
	SessionFactory factory=null;
	Session ses=null;
	 Transaction tx=null;
			cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml");
			factory=cfg.buildSessionFactory();
		ses=factory.openSession();
	
		tx=ses.beginTransaction();
		 String hql="insert into newMall(mallid,item_name,item_price,item_quantity) "
		 			+ "select bazarid,item_name,item_price,item_quantity from bigbazarModel ";
		 Query q=ses.createQuery(hql);
		 			int c=q.executeUpdate();
		 			//int count=Integer.parseUnsignedInt(c);
		 			tx.commit();
		 			System.out.println("\t\t"+c+" rows Copied Successfully...");
		 		
		 			factory.close();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_UniqueResult_ExecuteUpdate_CopyData_Delete_Update,代码行数:22,代码来源:copy_HQL.java

示例9: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
	Configuration cfg=null;
	SessionFactory factory=null;
	Session ses=null;
	 Transaction tx=null;
			cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml");
			factory=cfg.buildSessionFactory();
		ses=factory.openSession();
	
		tx=ses.beginTransaction();
		 String hql="update bigbazarModel set item_price=:price where bazarid=:id";
		 Query q=ses.createQuery(hql);
		 		q.setParameter("id", 1002);
		 		q.setParameter("price", 60.0f);
		 			int c=q.executeUpdate();
		 			//int count=Integer.parseUnsignedInt(c);
		 			tx.commit();
		 			System.out.println("\t\t"+c+" rows Updated");
		 		
		 			factory.close();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_UniqueResult_ExecuteUpdate_CopyData_Delete_Update,代码行数:23,代码来源:update_HQL.java

示例10: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
    String path = "hibernate.cfg.xml";
    Configuration cfg = new Configuration().configure(path);

    SessionFactory sessionFactory = cfg.buildSessionFactory();

    Session session = sessionFactory.openSession();
    session.beginTransaction();
    User user = new User();
    user.setId("443");
    user.setName("baa");
    session.save(user);
    // session.close();
    session.getTransaction().commit();
    sessionFactory.close();
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:17,代码来源:InHibernate.java

示例11: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
    String path = "hibernate.cfg.xml";
    Configuration cfg = new Configuration().configure(path);

    SessionFactory sessionFactory = cfg.buildSessionFactory();

    Session session = sessionFactory.openSession();
    session.beginTransaction();
    User user = new User();
    user.setId("46");
    user.setName("aaa");
    session.save(user);
    // session.close();
    session.getTransaction().commit();
    sessionFactory.close();
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:17,代码来源:InHibernate.java

示例12: hibernate

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void hibernate() {
  SessionFactory sessionFactory = createSessionFactory(false);
  Session session = sessionFactory.openSession();

  Employee employee = new Employee();
  session.beginTransaction();
  session.save(employee);
  session.getTransaction().commit();
  session.close();
  sessionFactory.close();

  assertNotNull(employee.id);

  List<MockSpan> finishedSpans = mockTracer.finishedSpans();
  assertEquals(8, finishedSpans.size());

  checkSpans(finishedSpans);
  assertNull(mockTracer.activeSpan());
}
 
开发者ID:opentracing-contrib,项目名称:java-jdbc,代码行数:21,代码来源:HibernateTest.java

示例13: hibernate_with_parent

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void hibernate_with_parent() {
  try (Scope ignored = mockTracer.buildSpan("parent").startActive(true)) {
    SessionFactory sessionFactory = createSessionFactory(false);
    Session session = sessionFactory.openSession();

    session.beginTransaction();
    session.save(new Employee());
    session.save(new Employee());
    session.getTransaction().commit();
    session.close();
    sessionFactory.close();
  }

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(11, spans.size());
  checkSameTrace(spans);
  assertNull(mockTracer.activeSpan());
}
 
开发者ID:opentracing-contrib,项目名称:java-jdbc,代码行数:20,代码来源:HibernateTest.java

示例14: hibernate_with_parent_and_active_span_only

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
@Test
public void hibernate_with_parent_and_active_span_only() {
  try (Scope ignored = mockTracer.buildSpan("parent").startActive(true)) {
    SessionFactory sessionFactory = createSessionFactory(true);
    Session session = sessionFactory.openSession();

    session.beginTransaction();
    session.save(new Employee());
    session.save(new Employee());
    session.getTransaction().commit();
    session.close();
    sessionFactory.close();
  }

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(11, spans.size());
  checkSameTrace(spans);
  assertNull(mockTracer.activeSpan());
}
 
开发者ID:opentracing-contrib,项目名称:java-jdbc,代码行数:20,代码来源:HibernateTest.java

示例15: main

import org.hibernate.SessionFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
	Configuration cfg=null;
	SessionFactory sf=null;
	Session ses=null;
	//activate the hibernate framework
		cfg=new Configuration().configure("hibernate.cfg.xml");
		//build the session factory
		sf=cfg.buildSessionFactory();
		//open/get the session
		ses=sf.openSession();
		
		//create the model class object and set the data
		Employee e=new Employee();
		
		//create then sql query
		
		String sql="SELECT * FROM EMP_NATIVE";
			SQLQuery q=ses.createSQLQuery(sql);
			q.addEntity(Employee.class);
	//execute the query
		List<Employee> emplist=q.list();
		//display the data
		emplist.forEach(row->{
			System.out.println("\t"+row.getId()+"\t"+row.getName()+"\t"+row.getSal());
		});
	
				//close the session factory and session
				ses.close();
				sf.close();
	
}
 
开发者ID:pratikdimble,项目名称:Hibernate_Native_SQL_Maven_Annotation,代码行数:32,代码来源:TestClass.java


注:本文中的org.hibernate.SessionFactory.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。