用正则替换文章中的表情(例如微博)
2012-08-10 16:05
204 查看
java 代码
public
class
HibernateSessionFactory {
private
static
String CONFIG_FILE_LOCATION =
"/hibernate.cfg.xml"
;
private
static
final
ThreadLocal threadLocal =
new
ThreadLocal();
private
static
final
Configuration cfg =
new
Configuration();
private
static
org.hibernate.SessionFactory sessionFactory;
public
static
Session currentSession()
throws
HibernateException {
Session session = (Session) threadLocal.get();
if
(session ==
null
|| !session.isOpen()) {
if
(sessionFactory ==
null
) {
try
{
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
}
catch
(Exception e) {
System.err.println(
"%%%% Error Creating SessionFactory %%%%"
);
e.printStackTrace();
}
}
session = (sessionFactory !=
null
) ? sessionFactory.openSession():
null
;
threadLocal.set(session);
}
return
session;
}
public
static
void
closeSession()
throws
HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(
null
);
if
(session !=
null
) {
session.close();
}
}
private
HibernateSessionFactory() {
}
}
java 代码
public
class
DAOTool {
public
Object load (Object object,Integer id) {
Session session = HibernateSessionFactory.currentSession();
return
session.load(object.
class
, id);
}
public
Object get (Object object ,Integer id) {
Session session = HibernateSessionFactory.currentSession();
return
session.get(object.
class
, id);
}
public
List find(String hql) {
Session session = HibernateSessionFactory.currentSession();
return
session.createQuery(hql).list();
}
public
Serializable save (Object obj) {
Session session = HibernateSessionFactory.currentSession();
return
session.save(obj);
}
public
void
update(Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.update(obj);
}
public
void
update(String hql, Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.update(hql, obj);
}
public
void
delete(Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.delete(obj);
}
public
void
delete(String hql, Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.delete(hql, obj);
}
}
public
class
HibernateSessionFactory {
private
static
String CONFIG_FILE_LOCATION =
"/hibernate.cfg.xml"
;
private
static
final
ThreadLocal threadLocal =
new
ThreadLocal();
private
static
final
Configuration cfg =
new
Configuration();
private
static
org.hibernate.SessionFactory sessionFactory;
public
static
Session currentSession()
throws
HibernateException {
Session session = (Session) threadLocal.get();
if
(session ==
null
|| !session.isOpen()) {
if
(sessionFactory ==
null
) {
try
{
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
}
catch
(Exception e) {
System.err.println(
"%%%% Error Creating SessionFactory %%%%"
);
e.printStackTrace();
}
}
session = (sessionFactory !=
null
) ? sessionFactory.openSession():
null
;
threadLocal.set(session);
}
return
session;
}
public
static
void
closeSession()
throws
HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(
null
);
if
(session !=
null
) {
session.close();
}
}
private
HibernateSessionFactory() {
}
}
java 代码
public
class
DAOTool {
public
Object load (Object object,Integer id) {
Session session = HibernateSessionFactory.currentSession();
return
session.load(object.
class
, id);
}
public
Object get (Object object ,Integer id) {
Session session = HibernateSessionFactory.currentSession();
return
session.get(object.
class
, id);
}
public
List find(String hql) {
Session session = HibernateSessionFactory.currentSession();
return
session.createQuery(hql).list();
}
public
Serializable save (Object obj) {
Session session = HibernateSessionFactory.currentSession();
return
session.save(obj);
}
public
void
update(Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.update(obj);
}
public
void
update(String hql, Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.update(hql, obj);
}
public
void
delete(Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.delete(obj);
}
public
void
delete(String hql, Object obj) {
Session session = HibernateSessionFactory.currentSession();
session.delete(hql, obj);
}
}
相关文章推荐
- iOS开发进阶 - 富文本正则替换表情
- ASP.NET正则实现表情替换为图片,如[hanx]替换为<img src="img/hanx.gif"/>
- iOS开发进阶 - 富文本正则替换表情
- 织梦正则替换文章内容内链变成绝对路径
- 分享C#使用正则替换文章屏蔽词,速度超快1毫秒处理1500个屏蔽词,6KB的文章
- [大笑][哈哈]正则表达式替换文本内容中的表情图片
- js 表情正则替换处理
- 正则url 匹配 替换A标签 微博使用
- 用正则表达式替换文章中的文字 js
- IOS开发微博中涉及到的一些正则表达式(表情,话题,链接,@)
- 运用spinner和正则表达式pattern来实现文字中表情文字的替换
- 使用正则表达式替换表情符号核心代码
- PHP正则提取或替换img标记属性实现文章预览
- PHP正则提取或替换img标记属性实现文章预览
- qq表情正则替换
- 使用正则替换文章屏蔽词,1500个屏蔽词,6KB的文章,替换用时1毫秒
- IOS开发微博中涉及到的一些正则表达式(表情,话题,链接,@)
- 使用正则表达式替换表情符号核心代码
- 使用正则替换文章屏蔽词
- 使用正则替换文章屏蔽词,1500个屏蔽词,6KB的文章,替换用时01毫秒