?? advertdao.java
字號:
package sample.dao;
import java.util.logging.Level;
import org.hibernate.HibernateException;
import sample.AdException;
import sample.Advert;
import sample.User;
public class AdvertDAO extends DAO {
public AdvertDAO() {
}
/**
* Stores (and detaches) the advert
*
* @param advert
* @throws AdException
*/
public Advert createAdvert(String title, String message, User user)
throws AdException
{
try {
Advert advert = new Advert(title,message,user);
HibernateHelper.getSession().save(advert);
return advert;
} catch ( HibernateException e ) {
log.log(Level.SEVERE, "", e);
throw new AdException("",e);
}
}
public void deleteAdvert(Advert advert)
throws AdException
{
try {
HibernateHelper.getSession().update(advert); //Attach advert
HibernateHelper.getSession().delete(advert); //Delete it from the database
} catch ( HibernateException e ) {
log.log(Level.SEVERE, "", e);
throw new AdException("",e);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -