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


Java HibernateUtil.closeFactory方法代码示例

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


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

示例1: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {

		Session ses = null;			//creating the session object
		Emp em = null;				
		Transaction tx = null;		//creating transaction object
		Scanner sc=new Scanner(System.in);		//creating scanner for user input

		ses = HibernateUtil.getSession();			//get the cgf,factory,session
		
			em = new Emp();		//creating the domain class object
			System.out.print("\n\t\tEnter the Account Holder Name: ");
			String name=sc.nextLine();
			System.out.print("\n\t\tEnter the Account Type: ");
			String type=sc.nextLine();
			System.out.print("\n\t\tEnter the Account Holder Balance: ");
			float bal=sc.nextFloat();
				
				em.setHoldername(name);
				em.setAcctype(type);
				em.setBalance(bal);
		try {
			tx = ses.beginTransaction();
			ses.save(em);
			tx.commit();
			System.out.println("object is saved  with account number: "+em.getAccno());
			//System.out.print("\n\t\tEnter the Account Holder Name: ");
		} catch (Exception e) {
			tx.rollback();

		}
		HibernateUtil.closeSession(ses);
    HibernateUtil.closeFactory();

		System.out.print("\n\t\t ==PROGRAMME BY PRATIK DIMBLE==\n\n\n");

	}
 
开发者ID:pratikdimble,项目名称:Hibernate-Versioning_HQL_Maven,代码行数:37,代码来源:ClientApp.java

示例2: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session ses=null;
	//get the session
	ses=HibernateUtil.getSession();
	//create the HQL query
	Query query=ses.createQuery("select pname,quantity from"
				+ " prod where price>=:id");
		//set the parameter to query
 	int value=500;
 		query=query.setParameter("id",value);
	//execute the query
	
	List<Object[]> list=query.list();
	//display the result
	 	for(Object[] row:list)
	 	{
	 		System.out.println("\t"+row[0]+"\t"+row[1]);
		}

		//close the session and session factory
		HibernateUtil.closeSession(ses);
		HibernateUtil.closeFactory();
System.out.print("\n\t\t ==PROGRAMME BY PRATIK DIMBLE==\n\n\n");
}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_Select_Queries_Specific,代码行数:25,代码来源:ClientApp_HQL_specific_multilple.java

示例3: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	//use dao
			DAO_Interface dao=DAO_Factory.getInstance();
			//call getList method usung object collection
			List<Object[]> list=dao.getList();
			//display the list
						for(Object[]row:list) {
							for(Object val:row) {

									System.out.println(val);
								}
									System.out.println();
						}
		//close the session factory
						HibernateUtil.closeFactory();
}
 
开发者ID:pratikdimble,项目名称:Hibernate_Native_SQL_Scalar_Using_DAO_Using_MAVEN,代码行数:18,代码来源:clientTest_Scalar.java

示例4: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session ses=null;
	Insuarance_DAO dao=null;
	Insurance_DAO_IMPL impl=new Insurance_DAO_IMPL();
	//get the session
	HibernateUtil.getSession();
	//use DAO
	dao=Insurance_DAO_Factory.getInstance();
	try {
	dao.savedata();
	}catch (Exception e) {
		e.getMessage();
	}
	//System.out.println(new Insurance_DAO_IMPL().savedata());
	HibernateUtil.closeFactory();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_Inheritance_Mapping_Table_Per_Class_Hierarchy_Using_DAO_Using_Maven,代码行数:18,代码来源:TestApp_setdata.java

示例5: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session ses=null;
	//Query query=null;
	
	ses=HibernateUtil.getSession();
	Query query=ses.createQuery("from Emp");
	List<Emp> list=query.list();
	for(Emp e:list) {
	System.out.println("\n\t\t***"+e);
	}
   	HibernateUtil.closeSession(ses);
	HibernateUtil.closeFactory();
System.out.print("\n\t\t ==PROGRAMME BY PRATIK DIMBLE==\n\n\n");
}
 
开发者ID:pratikdimble,项目名称:Hibernate-Versioning_HQL_Maven,代码行数:15,代码来源:ClientApp_HQL.java

示例6: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {

			//use DAO
		DAO_Interface dao=DAO_Factory.getInstance();
		//call method and get the list
		List<product> list=dao.list();
		//display the list
			list.forEach(row->{
				System.out.println(row);
			});
			//close the session factory
			HibernateUtil.closeFactory();
	}
 
开发者ID:pratikdimble,项目名称:Hibernate_Criteria_Queries_Using_DAO_Using_MAVEN,代码行数:14,代码来源:ClientApp.java

示例7: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {

		//use DAO
		DAO_Interface dao=DAO_Factory.getInstance();
		//call method
			dao.restricions();
			//close the session factory
			HibernateUtil.closeFactory();

	}
 
开发者ID:pratikdimble,项目名称:Hibernate_Criteria_Queries_Using_DAO_Using_MAVEN,代码行数:11,代码来源:ClientApp_LT_GT_LE_GE_EQ.java

示例8: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Insuarance_DAO dao=null;
	//get the session
	HibernateUtil.getSession();
	//use DAO
	dao=Insurance_DAO_Factory.getInstance();
	dao.getdata();
	HibernateUtil.closeFactory();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_Inheritance_Mapping_Table_Per_Sub_Class_XML_Using_DAO_Using_Maven,代码行数:11,代码来源:TestApp_getdata.java

示例9: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session ses=null;
	Insuarance_DAO dao=null;
	Insurance_DAO_IMPL impl=new Insurance_DAO_IMPL();
	//get the session
	HibernateUtil.getSession();
	//use DAO
	dao=Insurance_DAO_Factory.getInstance();
	dao.savedata();
	
	//System.out.println(new Insurance_DAO_IMPL().savedata());
	HibernateUtil.closeFactory();

}
 
开发者ID:pratikdimble,项目名称:Hibernate_Inheritance_Mapping_Table_Per_Sub_Class_XML_Using_DAO_Using_Maven,代码行数:15,代码来源:TestApp_setdata.java

示例10: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	//use dao
	DAO_Interface dao=DAO_Factory.getInstance();
	//call getList method
	List<demo> list=dao.getList();
	//display the list
				for(demo row:list) {

					System.out.println("\n"+row);
				}
//close the session factory
				HibernateUtil.closeFactory();
}
 
开发者ID:pratikdimble,项目名称:Hibernate_Native_SQL_Using_DAO_Using_MAVEN,代码行数:15,代码来源:clientTest.java

示例11: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {

		Session ses = null;			//creating the session object
		Transaction tx = null;		//creating transaction object
		Scanner sc=new Scanner(System.in);		//creating scanner for user input

		ses = HibernateUtil.getSession();			//get the cgf,factory,session
		
				//creating the domain class object
			System.out.print("\n\t\tEnter the Account Holder Number:");
			int no=sc.nextInt();
			float bal = 0;
			boolean flag=false;
				
				Object ob=ses.get(Emp.class.getName(),no);
				Emp e=(Emp)ob;
				if(ob!=null)
				{
					flag=true;
				System.out.println("\n\t\t"+e);
				System.out.println("\n\t\tTransactions Left: "+e.getVersion());
		try {
			tx = ses.beginTransaction();

				
			if (e.getVersion()>5)
			{
				System.out.println("\n\t\tNo Free Transactions");
			}
			
				System.out.print("\n\t\tEnter the Amount to Withdraw: ");
				int amt1=sc.nextInt();
				bal=e.getBalance()-(amt1);
			
			e.setBalance(bal);
			ses.update(e);
			tx.commit();
			System.out.println("\n\t\tWithdrawn Money: "+amt1);
			System.out.println("\n\t\tBalance: "+e.getBalance());
			if((5-e.getVersion())!=0)
			{			System.out.println("\n\t\tTransactions Left: "+(5-e.getVersion()));
			}else
			System.out.println("\t\tNo Free Transactions Available");
				

			} //try
			catch (HibernateException he) {
			System.out.println("\t\tRECORD NOT FOUND");
			tx.rollback();
			he.printStackTrace();
			flag=false;
		}//catch
		catch (Exception e3) {
			tx.rollback();
			e3.printStackTrace();
			flag=false;
		}//catch
		finally
		{
			try {
				
				ses.close();
				HibernateUtil.closeFactory();
				flag=false;
			}//catch
			catch (Exception e2) {
				e2.printStackTrace();
				flag=false;
			}//catch
		}//finally
		
				System.out.print("\n\t\t ==PROGRAMME BY PRATIK DIMBLE==\n\n\n");
	}//main
}
 
开发者ID:pratikdimble,项目名称:Hibernate-Versioning_HQL_Maven,代码行数:75,代码来源:ClientApp_withdraw.java

示例12: main

import com.pratik.utility.HibernateUtil; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session ses=null;
	//product prod=null;

	ses=HibernateUtil.getSession();
	Query query=null;
	query=ses.createQuery(hql_select_one);
		
		List<String> list=query.list();
		
			for(String p:list)
			{
				System.out.println(p);
			}
			
			HibernateUtil.closeFactory();
			
			System.out.print("\n\t\t ==PROGRAMME BY PRATIK DIMBLE==\n\n\n");

		
	
	

}
 
开发者ID:pratikdimble,项目名称:Hibernate_HQL_Select_Queries_Specific,代码行数:25,代码来源:ClientApp_HQL_specific_one.java


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