⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 songtypeservice.java

📁 本代码是点歌系统的部分代码实现了部分功能
💻 JAVA
字号:
package music.service;

import music.hibernate.SongType;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;



public class SongTypeService {
	


	public void insertSongType(SongType songtype)
	{
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session session = sf.openSession();
		Transaction tx = session.beginTransaction();
		
		session.save(songtype);
		tx.commit();
		session.close();
	}
	
	/**
	 * 
	 * @param id
	 * @return
	 */
	public SongType loadOneSongType(int i){
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session session = sf.openSession();
		Transaction tx = session.beginTransaction();
		SongType type = (SongType)session.get(SongType.class,i);
		tx.commit();
		session.close();
		return type;
	}
	
//	public MusicType loadOnMusicTypeName(Integer id)
//	{
//		SessionFactory sf = new Configuration().configure().buildSessionFactory();
//		Session session = sf.openSession();
//		
//		Transaction tx = session.beginTransaction();
//		String typeName = (String)session.get(MusicType.class, name);
//		tx.commit();
//		session.close();
//		return typeName;
//	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -