📄 songtypeservice.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 + -