- 浏览: 107662 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (60)
- javase (7)
- jsp (2)
- hibernate (5)
- webwork (0)
- spring (0)
- ajax (8)
- jbpm (1)
- flex (2)
- SQL Server (2)
- UML (0)
- ORACLE (3)
- CSS (0)
- CAS (1)
- EJB (0)
- Ruby (0)
- Linux (2)
- Windows (0)
- webservice (1)
- 中间件 (0)
- 设计重构需求 (2)
- 综合 (5)
- 人生目标 (2)
- web server (2)
- 分布式缓存 (1)
- 开源项目 (1)
- 集群&负载均衡 (1)
- 架构&设计&性能 (5)
- 项目管理 (1)
- android (1)
- Camel (2)
- ActiveMQ (1)
最新评论
-
key232323:
不一定,在方法体里最后一句写window.event.retu ...
IE6 下链接的写法问题 -
yoyo837:
请问这个可以 自己二次开发,实现ftp 软件使用 和跨语言代码 ...
Apache-FTP Server-1.0.0源码的初步研究 -
fengweiyou:
showModalDialog 方法要想子页面调用父页面的方法 ...
showModalDialog取得父窗口的方法 -
Anddy:
这头像好恶心!
JQuery-Form中的AjaxForm和AjaxSubmit的区别 -
sgp2004:
前边的都深入研究过了?挺不错的 呵呵
工作一年小菜鸟的书单
数据库:Oracle 9i
JDBC驱动:OJDBC14
开发环境:Eclipse-JEE
Spring版本:Spring 2.0.6
Hibernate版本:Hibernate Core 3.2.5/Hibernate Annotation 3.3.0/Hibernate Validator 3.0.0/Hibernate Search 3.0.0 Beta4
//jdbc.properties(JDBC配置文件)
Java代码
//hibernate.properties(Hibernate配置文件)
Java代码
hibernate.search.default.directory_provider=org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=E:/indexes
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.show_sql=false
hibernate.cache.use_query_cache=true
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate.hbm2ddl.auto=update
######以下是Hibernate Search的简单配置######
hibernate.search.default.directory_provider=org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=E:/indexes
//Foo.java(Hibernate POJO文件)
Java代码
@Entity
@Table(name = "search_foo")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Indexed(index = "search_foo")
public class Foo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
private Integer id;
@Column(nullable = false, length = 256)
@Field(name = "name", index = Index.TOKENIZED, store = Store.YES)
private String name;
@Lob
@Field(name = "content", index = Index.TOKENIZED, store = Store.YES)
private String content;
@Column(name = "post_time", nullable = false)
@DateBridge(resolution = Resolution.DAY)
private Calendar postTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Calendar getPostTime() {
return postTime;
}
public void setPostTime(Calendar postTime) {
this.postTime = postTime;
}
}
@Entity
@Table(name = "search_foo")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Indexed(index = "search_foo")
public class Foo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
private Integer id;
@Column(nullable = false, length = 256)
@Field(name = "name", index = Index.TOKENIZED, store = Store.YES)
private String name;
@Lob
@Field(name = "content", index = Index.TOKENIZED, store = Store.YES)
private String content;
@Column(name = "post_time", nullable = false)
@DateBridge(resolution = Resolution.DAY)
private Calendar postTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Calendar getPostTime() {
return postTime;
}
public void setPostTime(Calendar postTime) {
this.postTime = postTime;
}
}
//hibernate.cfg.xml(Hibernate配置文件)
Xml代码
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="com.itone.search.pojo.Foo"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="com.itone.search.pojo.Foo"/>
</session-factory>
</hibernate-configuration>
//applicationContext-conf.xml(加载.properties文件的配置文件)
Xml代码
//applicationContext-database.xml(数据源及SessionFactory定义文件)
Xml代码
//SpringMVC、Log4j、EHCache配置略
//FooManager.java(做全文检索示例)
Java代码
JDBC驱动:OJDBC14
开发环境:Eclipse-JEE
Spring版本:Spring 2.0.6
Hibernate版本:Hibernate Core 3.2.5/Hibernate Annotation 3.3.0/Hibernate Validator 3.0.0/Hibernate Search 3.0.0 Beta4
//jdbc.properties(JDBC配置文件)
Java代码
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver jdbc.url=jdbc:oracle:thin:@192.168.0.3:1521:itone jdbc.username=test jdbc.password=test jdbc.driverClassName=oracle.jdbc.driver.OracleDriver jdbc.url=jdbc:oracle:thin:@192.168.0.3:1521:itone jdbc.username=test jdbc.password=test
//hibernate.properties(Hibernate配置文件)
Java代码
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect hibernate.show_sql=false hibernate.cache.use_query_cache=true hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.hbm2ddl.auto=update######以下是Hibernate Search的简单配置######
hibernate.search.default.directory_provider=org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=E:/indexes
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.show_sql=false
hibernate.cache.use_query_cache=true
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate.hbm2ddl.auto=update
######以下是Hibernate Search的简单配置######
hibernate.search.default.directory_provider=org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=E:/indexes
//Foo.java(Hibernate POJO文件)
Java代码
@Entity
@Table(name = "search_foo")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Indexed(index = "search_foo")
public class Foo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
private Integer id;
@Column(nullable = false, length = 256)
@Field(name = "name", index = Index.TOKENIZED, store = Store.YES)
private String name;
@Lob
@Field(name = "content", index = Index.TOKENIZED, store = Store.YES)
private String content;
@Column(name = "post_time", nullable = false)
@DateBridge(resolution = Resolution.DAY)
private Calendar postTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Calendar getPostTime() {
return postTime;
}
public void setPostTime(Calendar postTime) {
this.postTime = postTime;
}
}
@Entity
@Table(name = "search_foo")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Indexed(index = "search_foo")
public class Foo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
private Integer id;
@Column(nullable = false, length = 256)
@Field(name = "name", index = Index.TOKENIZED, store = Store.YES)
private String name;
@Lob
@Field(name = "content", index = Index.TOKENIZED, store = Store.YES)
private String content;
@Column(name = "post_time", nullable = false)
@DateBridge(resolution = Resolution.DAY)
private Calendar postTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Calendar getPostTime() {
return postTime;
}
public void setPostTime(Calendar postTime) {
this.postTime = postTime;
}
}
//hibernate.cfg.xml(Hibernate配置文件)
Xml代码
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="com.itone.search.pojo.Foo"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="com.itone.search.pojo.Foo"/>
</session-factory>
</hibernate-configuration>
//applicationContext-conf.xml(加载.properties文件的配置文件)
Xml代码
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> <value>classpath*:hibernate.properties</value> </list> </property> </bean> </beans> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> <value>classpath*:hibernate.properties</value> </list> </property> </bean> </beans>
//applicationContext-database.xml(数据源及SessionFactory定义文件)
Xml代码
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/> <property name="configLocation" value="/WEB-INF/classes/hibernate.cfg.xml"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.search.default.directory_provider">${hibernate.search.default.directory_provider}</prop> <prop key="hibernate.search.default.indexBase">${hibernate.search.default.indexBase}</prop> </props> </property> </bean> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator"/> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"/> </beans> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/> <property name="configLocation" value="/WEB-INF/classes/hibernate.cfg.xml"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.search.default.directory_provider">${hibernate.search.default.directory_provider}</prop> <prop key="hibernate.search.default.indexBase">${hibernate.search.default.indexBase}</prop> </props> </property> </bean> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator"/> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"/> </beans> //applicationContext-manager.xml(Manager定义文件) Xml代码 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="baseTxService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="proxyTargetClass" value="true"/> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- Authentication manager for login and role checking --> <bean id="fooManager" parent="baseTxService"> <property name="target"> <bean class="com.itone.search.manager.FooManager"/> </property> </bean> </beans> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="byName"> <bean id="baseTxService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="proxyTargetClass" value="true"/> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- Authentication manager for login and role checking --> <bean id="fooManager" parent="baseTxService"> <property name="target"> <bean class="com.itone.search.manager.FooManager"/> </property> </bean> </beans>
//SpringMVC、Log4j、EHCache配置略
//FooManager.java(做全文检索示例)
Java代码
package com.itone.search.manager; import java.util.List; import org.apache.lucene.analysis.StopAnalyzer; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.Query; import org.hibernate.search.FullTextQuery; import org.hibernate.search.FullTextSession; import com.itone.search.pojo.Foo; public class FooManager extends BaseManager<Foo> { @SuppressWarnings("unchecked") public void testQuery() throws Exception { QueryParser parser = new QueryParser("name", new StopAnalyzer()); Query luceneQuery = parser.parse("name:Jack"); FullTextSession s = Search.createFullTextSession(getSession()); FullTextQuery query = s.createFullTextQuery(luceneQuery, Foo.class); List<Foo> result = query.list(); for(Foo f : result) { System.out.println("ID:" + f.getId()); System.out.println("NAME:" + f.getName()); System.out.println("CONTENT:" + f.getContent()); System.out.println("POSTTIME:" + f.getPostTime()); } } }
发表评论
-
PowerDesigner 12.5 导致 Word 2003文档内容无法选中以及点击鼠标没反应的问题
2010-12-30 09:20 1424几个月前刚发过关于PowerDesigner 11导致的 wo ... -
清除ATI右键菜单项
2010-12-27 13:16 957删除注册表HKEY_CLASSES_ROOT\Director ... -
2010今年主题
2010-10-28 15:28 707主题:高级数据库,IT项目管理,数据仓库,算法,深入UML,深 ... -
FCK 禁止复制链接到编辑框
2010-10-25 16:28 940FCKeditor设置文件 "fckconfig.j ...
相关推荐
在Flex+Spring+Hibernate的架构中,Hibernate作为数据访问层,负责与数据库之间的交互,为Spring服务层提供数据存储和检索功能。 在该示例中,"bsh"可能是指BeanShell,这是一个小型、轻量级的Java脚本语言,有时在...
这个示例项目是基于这三个框架的整合应用,用于实现一个基本的用户登录功能。 **Struts2** 是一个用于构建MVC(Model-View-Controller)架构的开源框架,它在ActionServlet的基础上发展而来,提供了更灵活的控制层...
总结来说,这个示例项目是一个完整的Java应用框架,展示了如何优雅地集成Compass 2.0、Spring和Hibernate,实现一个功能强大的、支持全文搜索的持久层解决方案。它不仅有助于理解这三个框架的基本用法,还提供了实践...
- **Hibernate Search 3.4.0.Final**:提供了基于Lucene的全文检索功能,方便地将全文检索功能集成到Hibernate应用中。 #### 四、整体架构概述 此项目构建了一个集成了全文检索功能的应用系统,具体架构如下: 1....
Hibernate Search是Hibernate ORM框架的一个扩展,它提供了在数据库中进行全文本搜索的功能。"dis"可能是“distribution”的缩写,意味着这是一个完整发布的包,包含了所有必要的组件和库。 **描述解析:** 描述中...
"easyui+spring+hibernate示例,带权限管理"的项目正是基于这样的需求构建的,它结合了三种主流的技术栈:EasyUI、Spring和Hibernate,用于创建一个具备完整权限控制功能的应用系统。下面将详细阐述这三个关键组件...
### Spring + Hibernate 详解与配置 #### Spring框架概述 Spring框架是一个开源的、轻量级的应用框架,旨在简化企业级应用开发。它提供了一个全面的编程模型,支持从Web到数据访问等各种应用需求。Spring的核心...
本示例将通过一个简单的网站登录功能来展示如何使用Struts、Hibernate和Spring构建一个轻量级的企业级Java应用。整个示例将在MyEclipse IDE中完成。 ### 预备工作 首先,需要准备MySQL数据库。假设已经安装了MySQL...
Struts1.2、Spring1.2和Hibernate3.1是经典的Java企业级开发框架组合,通常被称为SSH(Struts + Spring + Hibernate)集成。这个整合示例代码提供了一个全面的学习资源,帮助开发者理解如何将这三个强大的框架有效地...
本教程将深入探讨如何将`WebService`(基于SOAP协议的服务)与Java开发中的两大支柱——`Spring`框架和`Hibernate`ORM工具进行整合,同时使用`MySQL`作为数据库。这个集成项目是一个简单的示例,旨在帮助开发者了解...
本项目“spring hibernate struts login2”是一个基于这三个框架实现的登录功能示例,旨在帮助开发者理解如何将这三个框架整合起来,构建一个完整的MVC(Model-View-Controller)架构的应用程序。 首先,让我们深入...
这个简单的示例展示了如何结合Compass和Lucene在Struts2+Spring2+Hibernate3环境中实现全文检索功能。通过这种方式,你可以轻松地在应用程序中添加强大的搜索功能,让用户能够快速找到他们需要的信息。随着需求的...
标题"Struts Spring Hibernate MyEclipse的Login Demo"指的是一个使用这四大技术实现的登录示例项目。这个项目可能包含了一个完整的登录功能,包括用户输入用户名和密码,验证身份,并根据结果重定向到不同的页面。 ...
开发者可能已经实现了使用Spring管理Hibernate的持久化操作,通过Struts2处理HTTP请求并展示结果,同时利用Lucene进行全文检索。这展示了如何将这些技术融合在一起,形成一个完整的Web应用解决方案,其中可能包括...
通过本文的介绍,我们不仅了解了 Struts2、Spring、Hibernate 和 ExtJS 的基本概念和特点,还详细阐述了如何将这些技术栈整合起来构建一个实际的 Tree 示例。这种方式不仅提高了开发效率,还能更好地满足企业级应用...
结合这三个框架,我们可以创建一个高效的三层架构:Struts2负责前端请求的接收和处理,Spring管理业务逻辑和依赖,Hibernate处理数据存储和检索。通过Struts2的Action,我们可以调用Spring管理的Service层,Service...