Hibernate SVN: r10751 - branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-07 09:48:43 -0500 (Tue, 07 Nov 2006)
New Revision: 10751
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
Log:
HHH-2219
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-11-07 13:53:26 UTC (rev 10750)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-11-07 14:48:43 UTC (rev 10751)
@@ -75,9 +75,9 @@
factory.setSuperclass( interfaces.length == 1 ? persistentClass : null );
factory.setInterfaces( interfaces );
factory.setFilter( FINALIZE_FILTER );
- factory.setHandler( instance );
Class cl = factory.createClass();
final HibernateProxy proxy = ( HibernateProxy ) cl.newInstance();
+ ( ( ProxyObject ) proxy ).setHandler( instance );
instance.constructed = true;
return proxy;
}
18 years, 2 months
Hibernate SVN: r10750 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-07 08:53:26 -0500 (Tue, 07 Nov 2006)
New Revision: 10750
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
Log:
todo
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2006-11-07 13:44:49 UTC (rev 10749)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2006-11-07 13:53:26 UTC (rev 10750)
@@ -335,7 +335,7 @@
targetKey = toForeignKey;
}
- boolean uniqueReference = isUniqueReference(targetKey);
+ boolean uniqueReference = isUniqueReference(targetKey); // TODO: need to look one step further for many-to-many!
foreignKeyTable = TableIdentifier.create( targetKey.getTable() );
TableIdentifier foreignKeyReferencedTable = TableIdentifier.create( targetKey.getReferencedTable() );
18 years, 2 months
Hibernate SVN: r10749 - branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-07 08:44:49 -0500 (Tue, 07 Nov 2006)
New Revision: 10749
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java
Log:
fix possible statement leak in junittest
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java 2006-11-07 13:44:36 UTC (rev 10748)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java 2006-11-07 13:44:49 UTC (rev 10749)
@@ -116,7 +116,52 @@
}
+ public void testAnnotationColumnDefaults() {
+ PersistentClass classMapping = getCfg().getClassMapping("org.hibernate.tool.hbm2x.Article");
+ Cfg2JavaTool cfg2java = new Cfg2JavaTool();
+ POJOClass clazz = cfg2java.getPOJOClass(classMapping);
+
+ Property p = classMapping.getProperty("content");
+
+ String string = clazz.generateAnnColumnAnnotation( p );
+
+ assertNotNull(string);
+ assertEquals(-1, string.indexOf("unique="));
+ assertTrue(string.indexOf("nullable=")>=0);
+ assertEquals(-1, string.indexOf("insertable="));
+ assertEquals(-1, string.indexOf("updatable="));
+ assertTrue(string.indexOf("length=10000")>0);
+
+ p = classMapping.getProperty("name");
+ string = clazz.generateAnnColumnAnnotation( p );
+
+ assertNotNull(string);
+ assertEquals(-1, string.indexOf("unique="));
+ assertTrue(string.indexOf("nullable=")>=0);
+ assertEquals(-1, string.indexOf("insertable="));
+ assertTrue(string.indexOf("updatable=false")>0);
+ assertTrue(string.indexOf("length=100")>0);
+
+
+ classMapping = getCfg().getClassMapping( "org.hibernate.tool.hbm2x.Train" );
+ clazz = cfg2java.getPOJOClass(classMapping);
+
+ p = classMapping.getProperty( "name" );
+ string = clazz.generateAnnColumnAnnotation( p );
+ assertNotNull(string);
+ assertTrue(string.indexOf("unique=true")>0);
+ assertTrue(string.indexOf("nullable=")>=0);
+ assertEquals(-1, string.indexOf("insertable="));
+ assertEquals(-1,string.indexOf("updatable="));
+ assertEquals(-1, string.indexOf("length="));
+
+ }
+ protected void tearDown() throws Exception {
+
+ //super.tearDown();
+ }
+
protected String getBaseForMappings() {
return "org/hibernate/tool/hbm2x/";
}
18 years, 2 months
Hibernate SVN: r10748 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-07 08:44:36 -0500 (Tue, 07 Nov 2006)
New Revision: 10748
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
Log:
HBX-810 Remove redundant generation of @Column default values in annotation codegen
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-07 10:57:40 UTC (rev 10747)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-07 13:44:36 UTC (rev 10748)
@@ -411,19 +411,30 @@
}
else {
Column column = (Column) selectable;
- annotations.append( "@" + importType("javax.persistence.Column") + "(name=\"" ).append( column.getName() ).append( "\"" )
- .append( ", unique=" ).append( column.isUnique() )
- .append( ", nullable=" ).append( column.isNullable() )
- .append( ", insertable=" ).append( insertable )
- .append( ", updatable=" ).append( updatable );
+ annotations.append( "@" + importType("javax.persistence.Column") + "(name=\"" ).append( column.getName() ).append( "\"" );
+ if(column.isUnique()) {
+ annotations.append( ", unique=" ).append( column.isUnique() );
+ }
+ if(!column.isNullable()) {
+ annotations.append( ", nullable=" ).append( column.isNullable() );
+ }
+
+ if(!insertable) {
+ annotations.append( ", insertable=" ).append( insertable );
+ }
+
+ if(!updatable) {
+ annotations.append( ", updatable=" ).append( updatable );
+ }
+
if (column.getPrecision() != Column.DEFAULT_PRECISION) {
annotations.append( ", precision=" ).append( column.getPrecision() );
}
- if (column.getScale() != Column.DEFAULT_SCALE) {
+ if (column.getScale() != Column.DEFAULT_SCALE) { // default is actually 0 in spec
annotations.append( ", scale=" ).append( column.getScale() );
}
- else if (column.getLength() != Column.DEFAULT_LENGTH){
+ else if (column.getLength() != Column.DEFAULT_LENGTH){ // the default is actually 0 in spec
annotations.append( ", length=" ).append( column.getLength() );
}
18 years, 2 months
Hibernate SVN: r10747 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-07 05:57:40 -0500 (Tue, 07 Nov 2006)
New Revision: 10747
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
Log:
ask for MixedCaseQuotedId before anything else to remedy mysql drivers that lies.
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2006-11-07 06:22:12 UTC (rev 10746)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2006-11-07 10:57:40 UTC (rev 10747)
@@ -145,15 +145,18 @@
protected String caseForSearch(String value) throws SQLException {
// TODO: handle quoted requests (just strip it ?)
if(needQuote(value)) {
- if ( getMetaData().storesUpperCaseQuotedIdentifiers() ) {
+ if ( getMetaData().storesMixedCaseQuotedIdentifiers() ) {
+ return value;
+ } else if ( getMetaData().storesUpperCaseQuotedIdentifiers() ) {
return StringHelper.toUpperCase( value );
} else if( getMetaData().storesLowerCaseQuotedIdentifiers() ) {
return StringHelper.toLowerCase( value );
} else {
return value;
}
- }
- if ( getMetaData().storesUpperCaseIdentifiers() ) {
+ } else if ( getMetaData().storesMixedCaseQuotedIdentifiers() ) {
+ return value;
+ } else if ( getMetaData().storesUpperCaseIdentifiers() ) {
return StringHelper.toUpperCase( value );
} else if( getMetaData().storesLowerCaseIdentifiers() ) {
return StringHelper.toLowerCase( value );
18 years, 2 months
Hibernate SVN: r10746 - trunk/Hibernate3/doc/reference/zh-cn
by hibernate-commits@lists.jboss.org
Author: caoxg
Date: 2006-11-07 01:22:12 -0500 (Tue, 07 Nov 2006)
New Revision: 10746
Modified:
trunk/Hibernate3/doc/reference/zh-cn/master.xml
Log:
updated version No.
Modified: trunk/Hibernate3/doc/reference/zh-cn/master.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/master.xml 2006-11-07 06:15:35 UTC (rev 10745)
+++ trunk/Hibernate3/doc/reference/zh-cn/master.xml 2006-11-07 06:22:12 UTC (rev 10746)
@@ -375,6 +375,10 @@
</table>
<para>
+ v3.2版本在2006年11月份由曹晓钢更新。
+ </para>
+
+ <para>
关于我们
</para>
18 years, 2 months
Hibernate SVN: r10745 - in trunk/HibernateExt/metadata/doc/reference/zh_cn: . modules
by hibernate-commits@lists.jboss.org
Author: caoxg
Date: 2006-11-07 01:15:35 -0500 (Tue, 07 Nov 2006)
New Revision: 10745
Modified:
trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/entity.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/lucene.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/setup.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/validator.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/xml-overriding.xml
Log:
updated to v3.2.0GA
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -13,7 +13,7 @@
<subtitle>参考文档</subtitle>
- <releaseinfo>3.2.0 CR1</releaseinfo>
+ <releaseinfo>3.2.0.GA</releaseinfo>
<mediaobject>
<imageobject>
@@ -40,7 +40,10 @@
<sect1 id="preface-translate-comments-zh-cn">
<title>翻译说明</title>
- <para>本文档的翻译是在网络上协作进行的,也会不断根据Hibernate的升级进行更新。提供此文档的目的是为了减缓学习Hibernate的坡度,而非代替原文档。我们建议所有有能力的读者都直接阅读英文原文。若您对翻译有异议,或发现翻译错误,敬请不吝赐教,报告到如下地址:http://wiki.redsaga.com/confluence/display/HART/Home</para>
+ <para>本文档的翻译是在网络上协作进行的,也会不断根据Hibernate的升级进行更新。
+ 提供此文档的目的是为了减缓学习Hibernate的坡度,而非代替原文档。
+ 我们建议所有有能力的读者都直接阅读英文原文。若您对翻译有异议,或发现翻译错误,
+ 敬请不吝赐教,报告到如下地址:http://wiki.redsaga.com/confluence/display/HART/Home</para>
<table frame="topbot" id="redsaga-translate-team">
<title>Hibernate Annotation v3翻译团队</title>
@@ -223,7 +226,11 @@
<term>满江红.开源, http://www.redsaga.com</term>
<listitem>
- <para>从成立之初就致力于Java开放源代码在中国的传播与发展,与国内多个Java团体及出版社有深入交流。坚持少说多做的原则,目前有两个团队,“OpenDoc团队”与“翻译团队”,本翻译文档即为翻译团队作品。OpenDoc团队已经推出包括Hibernate、iBatis、Spring、WebWork的多份开放文档,并于2005年5月在Hibernate开放文档基础上扩充成书,出版了原创书籍:《深入浅出Hibernate》,本书400余页,适合各个层次的Hibernate用户。(http://www.redsaga.com/hibernate_book.html)敬请支持。</para>
+ <para>从成立之初就致力于Java开放源代码在中国的传播与发展,与国内多个Java团体及出版社有深入交流。
+ 坚持少说多做的原则,目前有两个团队,“OpenDoc团队”与“翻译团队”,本翻译文档即为翻译团队作品。
+ OpenDoc团队已经推出包括Hibernate、iBatis、Spring、WebWork的多份开放文档,
+ 并于2005年5月在Hibernate开放文档基础上扩充成书,出版了原创书籍:《深入浅出Hibernate》,
+ 本书400余页,适合各个层次的Hibernate用户。(http://www.redsaga.com/hibernate_book.html)敬请支持。</para>
</listitem>
</varlistentry>
@@ -242,13 +249,16 @@
<sect1 id="preface-translate-licence-zh-cn">
<title>版权声明</title>
- <para>Hibernate英文文档属于Hibernate发行包的一部分,遵循LGPL协议。本翻译版本同样遵循LGPL协议。参与翻译的译者一致同意放弃除署名权外对本翻译版本的其它权利要求。</para>
+ <para>Hibernate英文文档属于Hibernate发行包的一部分,遵循LGPL协议。本翻译版本同样遵循LGPL协议。
+ 参与翻译的译者一致同意放弃除署名权外对本翻译版本的其它权利要求。</para>
- <para>您可以自由链接、下载、传播此文档,或者放置在您的网站上,甚至作为产品的一部分发行。但前提是必须保证全文完整转载,包括完整的版权信息和作译者声明,并不能违反LGPL协议。这里“完整”的含义是,不能进行任何删除/增添/注解。若有删除/增添/注解,必须逐段明确声明那些部分并非本文档的一部分。</para>
+ <para>您可以自由链接、下载、传播此文档,或者放置在您的网站上,甚至作为产品的一部分发行。
+ 但前提是必须保证全文完整转载,包括完整的版权信息和作译者声明,并不能违反LGPL协议。
+ 这里“完整”的含义是,不能进行任何删除/增添/注解。若有删除/增添/注解,必须逐段明确声明那些部分并非本文档的一部分。</para>
</sect1>
</preface>
- <preface>
+ <preface id="preface" revision="1">
<title>前言</title>
<para>正如其他的ORM工具,Hibernate同样需要元数据来控制在不同数据表达形式之间的转化. 在Hibernate
@@ -259,7 +269,7 @@
在运行时(对于Hibernate来讲就是启动的时候)通过反射读取这些注解, 因此外部XML文件就不再需要了.</para>
<para>EJB3规范最终认可了透明化ORM的成功范例以及市场对于这种技术的兴趣.
- EJB3规范标准化了ORM的基础API而且在任何ORM持久化机制中使用元数据. <emphasis>Hibernate
+ EJB3规范对ORM的基础API以及在任一ORM持久化机制中所需的元数据进行了标准化. <emphasis>Hibernate
EntityManager</emphasis>实现了EJB3持久化规范中定义的编程接口和生命周期规则. 在<emphasis>Hibernate
Core</emphasis>的基础上再结合 <emphasis>Hibernate
Annotations</emphasis>就实现了一套完整(并且独立)的EJB3持久化解决方案.
@@ -267,12 +277,12 @@
Core</emphasis>. 这些都取决于项目的商业和技术上的实际需求. Hibernate允许你直接使用native APIs,如果有需要,
甚至可以直接操作JDBC和SQL.</para>
- <para>注意本文档基于Hibernate Annotations的预览版(遵从EJB 3.0/JSR-220最终草案).
- 这个版本和新规范中定义的最终概念已经非常接近了.我们的目标是提供一套完整的ORM注解,
- 包括EJB3的标准注解以及Hibernate3的扩展(后者是EJB3规范中没有涉及到的). 最终通过注解你可以完成任何可能的映射.详情参考<xref
- linkend="compliance" />.</para>
+ <para>这个版本基于EJB3.0最终发布版本/JPA规范(也就是JCP-220),该版本支持规范的所有特征
+ (包括可选项)。而Hibernate的那些和规范相比的特征和扩展也可以通过Hibernate的专有注解获得,
+ 虽然该版本的Hibernate特征覆盖程度非常高,不过仍然缺少了一部分,
+ 接下来Hibernate Team的目标就是完全覆盖Hibernate的所有特征。详情参考JIRA的计划图。</para>
- <para>EJB3最终草案修改了部分注解,
+ <para>如果你正在从以前的版本升级到最新的发布版本,
http://www.hibernate.org/371.html提供了从上一个版本到最新版本的迁移指南.</para>
</preface>
@@ -289,6 +299,7 @@
<appendix>
<title id="glossary">术语表</title>
- <para>Redsaga的wiki上维护了本文翻译过程中所参照的中英文对照的术语表,地址:http://wiki.redsaga.com/confluenc....</para>
+ <para>Redsaga的wiki上维护了本文翻译过程中所参照的中英文对照的术语表,
+ 地址:http://wiki.redsaga.com/confluence/display/HART/glossary.</para>
</appendix>
</book>
\ No newline at end of file
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/entity.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/entity.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/entity.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -5,14 +5,14 @@
<sect1 id="entity-overview" revision="1">
<title>简介</title>
- <para>本章内容覆盖了EJB3.0实体bean的注解规范以及Hibernate特有的扩展.</para>
+ <para>本章内容覆盖了EJB3.0(也就是JPA)实体的注解规范以及Hibernate特有的扩展.</para>
</sect1>
- <sect1 id="mapping" revision="1">
- <title>用EJB3注解进行映射</title>
-
+ <sect1 id="entity-mapping" revision="2">
+ <title>用EJB3/JPA注解进行映射</title>
+
<para>现在EJB3实体Bean是纯粹的POJO.实际上这表达了和Hibernate持久化实体对象同样的概念.
- 它们的映射都通过JDK5.0注解来定义(EJB3规范中的XML描述语法至今还没有最终定下来).
+ 它们的映射都通过JDK5.0注解来定义(EJB3规范已经定义了对应的XML描述语法).
注解分为两个部分,分别是逻辑映射注解和物理映射注解,
通过逻辑映射注解可以描述对象模型,类之间的关系等等,
而物理映射注解则描述了物理的schema,表,列,索引等等.
@@ -45,7 +45,7 @@
<literal>@Id</literal>注解则声明了该实体bean的标识属性.
其他的映射定义是隐式的.这种以隐式映射为主体,以显式映射为例外的配置方式在新的EJ3规范中处于非常重要的位置,
和以前的版本相比有了质的飞跃.
- 在上面这段代码中:Flight类映射到Flight表,并使用id列作为主键列.
+ 在上面这段代码中:Flight类映射到Flight表,并使用id列作为主键列.
</para>
<para>在对一个类进行注解时,你可以选择对它的的属性或者方法进行注解,根据你的选择,Hibernate的访问类型分别为
@@ -60,7 +60,7 @@
<para><literal>@Table</literal>是类一级的注解,
通过<literal>@Table</literal>注解可以为实体bean映射指定表(table),目录(catalog)和schema的名字.
- 如果没有定义<literal>@Table</literal>,那么系统自动使用默认值:实体的短类名(不附带包名).</para>
+ 如果没有定义<literal>@Table</literal>,那么系统自动使用默认值:实体的短类名(不附带包名).</para>
<programlisting>
@Entity
@@ -125,7 +125,7 @@
<para>实体bean中所有的非static非transient的属性都可以被持久化,
除非你将其注解为<literal>@Transient</literal>.所有没有定义注解的属性等价于在其上面添加了@Basic注解.
- 通过 <literal>@Basic</literal>注解可以声明属性的获取策略(fetch strategy):</para>
+ 通过 <literal>@Basic</literal>注解可以声明属性的获取策略(fetch strategy):</para>
<programlisting>public transient int counter; //transient property
@@ -163,7 +163,7 @@
</para>
<note>
- <para>为了启用属性级的延迟获取,你的类必须经过特殊处理(instrumented):
+ <para>为了启用属性级的延迟获取,你的类必须经过特殊处理(instrumented):
字节码将被织入原始类中来实现延迟获取功能,
详情参考Hibernate参考文档.如果不对类文件进行字节码特殊处理,
那么属性级的延迟获取将被忽略.</para>
@@ -217,7 +217,7 @@
<para>使用 <literal>@Column </literal>注解可将属性映射到列.
使用该注解来覆盖默认值(关于默认值请参考EJB3规范).
- 在属性级使用该注解的方式如下:</para>
+ 在属性级使用该注解的方式如下:</para>
<itemizedlist>
<listitem>
@@ -349,7 +349,7 @@
甚至覆盖该实体中原有的列映射.
组件类必须在类一级定义<literal>@Embeddable</literal>注解.
在特定的实体的关联属性上使用<literal>@Embedded</literal>和
- <literal>@AttributeOverride</literal>注解可以覆盖该属性对应的嵌入式对象的列映射:</para>
+ <literal>@AttributeOverride</literal>注解可以覆盖该属性对应的嵌入式对象的列映射:</para>
<programlisting>
@Entity
@@ -421,7 +421,7 @@
这样可以将其父类的属性持久(详情请查阅<literal>@MappedSuperclass</literal>).</para>
<para>Hibernate现在支持在嵌入式对象中使用关联注解(如<literal>@*ToOne</literal>和<literal>@*ToMany</literal>).
- 而EJB3规范尚不支持这样的用法。你可以使用 <literal>@AssociationOverride</literal>注解来覆写关联列.</para>
+ 而EJB3规范尚不支持这样的用法.你可以使用 <literal>@AssociationOverride</literal>注解来覆写关联列.</para>
<para>在同一个实体中使用两个同类型的嵌入对象,
@@ -462,7 +462,7 @@
</sect3>
</sect2>
- <sect2 id="mapping-identifier" label=""
+ <sect2 id="entity-mapping-identifier" label=""
xreflabel="Mapping identifier properties">
<title>映射主键属性</title>
@@ -511,11 +511,18 @@
多个<literal>@Id</literal>可以共享同一个identifier生成器,只要把generator属性设成相同的值就可以了.
通过<literal>@SequenceGenerator</literal> 和<literal>@TableGenerator</literal>,你可以配置不同的identifier生成器.
每一个identifier生成器都有自己的适用范围,可以是应用级(application level)和类一级(class level).
- 类一级的生成器在外部是不可见的,
- 而且类一级的生成器可以覆盖应用级的生成器.
- 应用级的生成器则定义在包一级(package level)(如<classname>package-info.java</classname>):</para>
+ 类一级的生成器在外部是不可见的,而且类一级的生成器可以覆盖应用级的生成器.
+ 应用级的生成器则定义在XML级(请参阅<xref linkend="xml-overriding" />):</para>
- <programlisting>
+ <programlisting><table-generator name="EMP_GEN"
+ table="GENERATOR_TABLE"
+ pk-column-name="key"
+ value-column-name="hi"
+ pk-column-value="EMP"
+ allocation-size="20"/>
+
+//and the annotation equivalent
+
@javax.persistence.TableGenerator(
name="EMP_GEN",
table="GENERATOR_TABLE",
@@ -524,16 +531,22 @@
pkColumnValue="EMP",
allocationSize=20
)
+
+<sequence-generator name="SEQ_GEN"
+ sequence-name="my_sequence"
+ allocation-size="20"/>
+
+//and the annotation equivalent
+
@javax.persistence.SequenceGenerator(
name="SEQ_GEN",
- sequenceName="my_sequence"
+ sequenceName="my_sequence",
+ allocationSize=20
)
-package org.hibernate.test.metadata;
</programlisting>
-
+
<para>
- 如果在<classname>org.hibernate.test.metadata</classname>包下面的
- <classname>package-info.java</classname>文件用于初始化EJB配置,
+ 如果JPA XML(如<filename>META-INF/orm.xml</filename>)用于定义生成器,
那么该文件中定义的 <literal>EMP_GEN</literal>
和<literal>SEQ_GEN</literal>都是应用级的生成器.
<literal>EMP_GEN</literal>定义了一个使用hilo算法
@@ -544,6 +557,19 @@
而<literal>valueColumnName</literal> "<literal>hi</literal>"中存储的是下一个要使用的最大值.
</para>
+ <para><literal>SEQ_GEN</literal>定义了一个sequence生成器,
+ 其使用名为<literal>my_sequence</literal>的sequence.
+ 该hilo算法基于sequence,该sequence分配的大小为20.
+ 注意,现在这个版本还不能处理sequence生成器的<literal>initialValue</literal>属性.
+ 默认分配的大小为50,因此如果你打算使用sequence,并且希望每次都重新获取新的值,务必将
+ 分配的大小设置为1.</para>
+
+ <note>
+ <para>EJB3.0规范已经不再支持Package级别的定义. 但是你仍然可以在包上使用
+ <literal>@GenericGenerator</literal>注解(详情请参考<xref
+ linkend="entity-hibspec-identifier" />).</para>
+ </note>
+
<para><literal>SEQ_GEN</literal>则定义了一个sequence 生成器,
其对应的sequence名为 <literal>my_sequence</literal>.
注意目前Hibernate Annotations还不支持sequence 生成器中的
@@ -747,7 +773,7 @@
<literal>InheritanceType.SINGLE_TABLE</literal>,并通过
<literal>@DiscriminatorColumn</literal>注解定义了辨别符列(还可以定义辨别符的类型).
最后,对于继承层次结构中的每个类,<literal>@DiscriminatorValue</literal>注解指定了用来辨别该类的值.
- 辨别符列的名字默认为 <literal>DTYPE</literal>,其默认值为实体名(在<literal>@Entity.name</literal>中定义),其类型
+ 辨别符列的名字默认为 <literal>DTYPE</literal>,其默认值为实体名(在<literal>@Entity.name</literal>中定义),其类型
为DiscriminatorType.STRING.
<classname>A320</classname>是子类,如果不想使用默认的辨别符,只需要指定相应的值即可.
其他的如继承策略,辨别标志字段的类型都是自动设定的.</para>
@@ -887,7 +913,7 @@
<title>一对一(One-to-one)</title>
<para>使用<literal>@OneToOne</literal>注解可以建立实体bean之间的一对一的关联.
- 一对一关联有三种情况:
+ 一对一关联有三种情况:
一是关联的实体都共享同样的主键,
二是其中一个实体通过外键关联到另一个实体的主键
(注意要模拟一对一关联必须在外键列上添加唯一约束).
@@ -952,15 +978,15 @@
</para>
<para>一对一关联可能是双向的.在双向关联中,
- 有且仅有一端是作为主体(owner)端存在的:主体端负责维护联接列(即更新).
+ 有且仅有一端是作为主体(owner)端存在的:主体端负责维护联接列(即更新).
对于不需要维护这种关系的从表则通过mappedBy属性进行声明.
<literal>mappedBy</literal>的值指向主体的关联属性.
在上面这个例子中,<literal>mappedBy</literal>的值为 <literal>passport</literal>.
最后,不必也不能再在被关联端(owned side)定义联接列了,因为已经在主体端进行了声明.</para>
- <para>如果在主体没有声明<literal>@JoinColumn</literal>,系统自动进行处理:
+ <para>如果在主体没有声明<literal>@JoinColumn</literal>,系统自动进行处理:
在主表(owner table)中将创建联接列,
- 列名为:主体的关联属性名+下划线+被关联端的主键列名.
+ 列名为:主体的关联属性名+下划线+被关联端的主键列名.
在上面这个例子中是<literal>passport_id</literal>,
因为<literal>Customer</literal>中关联属性名为<literal>passport</literal>,
<literal>Passport</literal>的主键是<literal>id</literal>.</para>
@@ -996,13 +1022,6 @@
而<literal>customer_fk</literal>外键列指向<literal>Customer</literal>表,
该信息定义为 <literal>joinColumns</literal>的属性值.</para>
- <para>这种关联可能是双向的.在双向关联中,
- 有且仅有一端是作为主体端存在的:主体端负责维护联接列(即更新).
- 对于不需要维护这种关系的从表则通过mappedBy属性进行声明.
- <literal>mappedBy</literal>的值指向主体的关联属性.
- 在上面这个例子中,<literal>mappedBy</literal>的值为 <literal>passport</literal>.
- 最后,不必也不能再在被关联端(owned side)定义联接列了,因为已经在主体端进行了声明.</para>
-
<para>你必须明确定义关联表名和关联列名.</para>
</sect3>
@@ -1026,7 +1045,7 @@
<para>其中<literal>@JoinColumn</literal>是可选的,关联字段默认值和一对一
(one to one)关联的情况相似,
- 列名为:主体的关联属性名+下划线+被关联端的主键列名.
+ 列名为:主体的关联属性名+下划线+被关联端的主键列名.
在这个例子中是<literal>company_id</literal>,
因为关联的属性是<literal>company</literal>,
<literal>Company</literal>的主键是<literal>id</literal>.</para>
@@ -1034,7 +1053,7 @@
<para><literal>@ManyToOne</literal>注解有一个名为<literal>targetEntity</literal>的参数,
该参数定义了目标实体名.通常不需要定义该参数,
因为在大部分情况下默认值(表示关联关系的属性类型)就可以很好的满足要求了.
- 不过下面这种情况下这个参数就显得有意义了:使用接口作为返回值而不是常见的实体.</para>
+ 不过下面这种情况下这个参数就显得有意义了:使用接口作为返回值而不是常见的实体.</para>
<programlisting>
@Entity()
@@ -1052,8 +1071,8 @@
...
</programlisting>
- <para>对于多对一也可以通过关联表的方式来映射。
- 通过<literal>@JoinTable</literal>注解可定义关联表,
+ <para>对于多对一也可以通过关联表的方式来映射.
+ 通过<literal>@JoinTable</literal>注解可定义关联表,
该关联表包含了指回实体表的外键(通过<literal>@JoinTable.joinColumns</literal>)
以及指向目标实体表的外键(通过<literal>@JoinTable.inverseJoinColumns</literal>).</para>
@@ -1076,15 +1095,16 @@
<sect3 id="entity-mapping-association-collections">
<title>集合类型</title>
- <sect4>
+ <sect4 id="entity-mapping-association-collections-overview"
+ revision="1">
<title>概况</title>
<para>你可以对 <classname>Collection </classname>,<literal>List</literal>
(指有序列表, 而不是索引列表),
<literal>Map</literal>和<classname>Set</classname>这几种类型进行映射.
EJB3规范定义了怎么样使用<literal>@javax.persistence.OrderBy</literal>
- 注解来对有序列表进行映射:
- 该注解接受的参数格式:用逗号隔开的(目标实体)属性名及排序指令,
+ 注解来对有序列表进行映射:
+ 该注解接受的参数格式:用逗号隔开的(目标实体)属性名及排序指令,
如<code>firstname asc, age desc</code>,如果该参数为空,则默认以id对该集合进行排序.
如果某个集合在数据库中对应一个关联表(association table)的话,你不能在这个集合属性上面使用@OrderBy注解.
对于这种情况的处理方法,请参考<xref linkend="entity-hibspec" />.
@@ -1092,13 +1112,13 @@
这个属性可以用<literal>@MapKey(name="myProperty")</literal>来声明.
如果使用<literal>@MapKey</literal>注解的时候不提供属性名,
系统默认使用目标实体的主键.
- map的key使用和属性相同的列:不需要为map key定义专用的列,因为map key实际上就表达了一个目标属性。
+ map的key使用和属性相同的列:不需要为map key定义专用的列,因为map key实际上就表达了一个目标属性.
注意一旦加载,key不再和属性保持同步,
也就是说,如果你改变了该属性的值,在你的Java模型中的key不会自动更新
(请参考<xref linkend="entity-hibspec" />).
- 很多人被<literal><map></literal>和<literal>@MapKey</literal>弄糊涂了。
+ 很多人被<literal><map></literal>和<literal>@MapKey</literal>弄糊涂了.
其他它们有两点区别.<literal>@MapKey</literal>目前还有一些限制,详情请查看论坛或者
- 我们的JIRA缺陷系统。
+ 我们的JIRA缺陷系统.
注意一旦加载,key不再和属性保持同步,
@@ -1138,7 +1158,16 @@
<entry>@org.hibernate.annotations.CollectionOfElements 或
@OneToMany 或 @ManyToMany</entry>
</row>
+
+ <row>
+ <entry>带主键的Bag语义(没有普通Bag语义的限制)</entry>
+ <entry>java.util.List, java.util.Collection</entry>
+
+ <entry>(@org.hibernate.annotations.CollectionOfElements 或
+ @OneToMany 或 @ManyToMany) 和 @CollectionId</entry>
+ </row>
+
<row>
<entry>List 语义</entry>
@@ -1166,13 +1195,8 @@
<entry>(@org.hibernate.annotations.CollectionOfElements 或
@OneToMany 或 @ManyToMany)
- 以及
- (空
- 或
- @org.hibernate.annotations.MapKey/MapKeyManyToMany(支持真正的map),
- 或
- @javax.persistence.MapKey</entry>
-
+ 以及(空或(a)org.hibernate.annotations.xn--mapkey/mapkeymanytomany(map)-1801dj24atl9b2o0edge,
+ 或(a)javax.persistence.MapKey</entry>
</row>
</tbody>
</tgroup>
@@ -1351,13 +1375,14 @@
(<literal>inversejoinColumns</literal>).</para>
</sect5>
- <sect5>
+ <sect5 id="entity-mapping-association-collection-manytomany-default"
+ revision="1">
<title>默认处理机制</title>
<para>通过联接表来建立单向一对多关联不需要描述任何物理映射.
表名由以下三个部分组成:主表(owner table)表名+下划线+从表(the other side table)表名.
- 指向主表的外键名:主表表名+下划线+主表主键列名
- 指向从表的外键名:主表所对应实体的属性名+下划线+从表主键列名
+ 指向主表的外键名:主表表名+下划线+主表主键列名
+ 指向从表的外键名:主表所对应实体的属性名+下划线+从表主键列名
指向从表的外键定义为唯一约束,用来表示一对多的关联关系.</para>
<programlisting>
@@ -1384,7 +1409,8 @@
</sect5>
</sect4>
- <sect4>
+ <sect4 id="eentity-mapping-association-collection-manytomany"
+ revision="">
<title>多对多(Many-to-many)</title>
<sect5>
@@ -1462,7 +1488,7 @@
}
</programlisting>
- <para>上面这个例子中,<literal>Store_Table</literal>作为联接表.
+ <para>上面这个例子中,<literal>Store_City</literal>作为联接表.
<literal>Store_id</literal>列是联接到<literal>Store</literal>表的外键.
而<literal>implantedIn_id</literal>列则联接到<literal>City</literal>表.</para>
@@ -1492,7 +1518,7 @@
<para>在上面这个例子中,<literal>Store_Customer</literal>作为联接表.
<literal>stores_id</literal>列是联接到<literal>Store</literal>表的外键,
- 而<literal>customers_id</literal>列联接到<literal>City</literal>表.</para>
+ 而<literal>customers_id</literal>列联接到<literal>Customer</literal>表.</para>
</sect5>
</sect4>
@@ -1551,7 +1577,7 @@
和<literal>@Embeddable</literal>两个注解.
还有一种方式是使用<literal>@EmbeddedId</literal>注解.注意所依赖的类必须实现
serializable以及实现<methodname>equals()</methodname>/<methodname>hashCode()</methodname>方法.
- 你也可以如<xref linkend="mapping-identifier" />一章中描述的办法使用<literal>@IdClass</literal>注解.</para>
+ 你也可以如<xref linkend="entity-mapping-identifier" />一章中描述的办法使用<literal>@IdClass</literal>注解.</para>
<programlisting>
@Entity
@@ -1690,22 +1716,24 @@
<sect1 id="entity-mapping-query">
<title>映射查询</title>
- <sect2>
- <title>映射EJBQL/HQL查询</title>
+ <sect2 id="entity-mapping-query-hql" label="Mapping JPAQL/HQL queries"
+ revision="1">
+ <title>映射JPAQL/HQL查询</title>
<para>使用注解还可以映射EJBQL/HQL查询.
- <literal>@NamedQuery</literal> 和<literal>@NamedQueries</literal>是可使用在类和包上的注解.
+ <literal>@NamedQuery</literal> 和<literal>@NamedQueries</literal>注解可使用在类和JPA XML文件中.
但是它们的定义在session factory/entity manager factory范围中是都可见的.
命名式查询通过它的名字和实际的查询字符串来定义.</para>
- <programlisting>
-javax.persistence.NamedQueries(
- @javax.persistence.NamedQuery(name="plane.getAll", query="select p from Plane p")
-)
-package org.hibernate.test.annotations.query;
-
+ <programlisting><entity-mappings>
+ <named-query name="plane.getAll">
+ <query>select p from Plane p</query>
+ </named-query>
+ ...
+</entity-mappings>
...
+
@Entity
@NamedQuery(name="night.moreRecentThan", query="select n from Night n where n.date >= :date")
public class Night {
@@ -1726,7 +1754,7 @@
<para>还可以通过定义 <literal>QueryHint</literal> 数组的<literal>hints</literal>
属性为查询提供一些hint信息.</para>
- <para>下面是目前可以使用的一些Hibernate hint:</para>
+ <para>下面是目前可以使用的一些Hibernate hint:</para>
<para></para>
@@ -1806,10 +1834,13 @@
<para>你还可以映射本地化查询(也就是普通SQL查询).
不过这需要你使用<literal>@SqlResultSetMapping</literal>注解来描述SQL的resultset的结构
- (如果你打算定义多个结果集映射,可是使用<literal>@SqlResultSetMappings</literal>).
+ (如果你打算定义多个结果集映射,可是使用<literal>@SqlResultSetMappings</literal>).
<literal>@SqlResultSetMapping</literal>和<literal>@NamedQuery</literal>,
- <literal>@SqlResultSetMapping</literal>一样,可以定义在类和包一级.
+ <literal>@SqlResultSetMapping</literal>一样,可以定义在类和JPA XML文件中.
但是<literal>@SqlResultSetMapping</literal>的作用域为应用级.
+ </para>
+
+ <para>
下面我们会看到,<literal>@NamedNativeQuery</literal> 注解中
<literal>resultSetMapping</literal>参数值为<literal>@SqlResultSetMapping</literal>的名字.
结果集映射定义了通过本地化查询返回值和实体的映射.
@@ -1883,7 +1914,7 @@
在这个例子中,<literal>model</literal>属性绑定到<literal>model_txt</literal>列.
如果和相关实体的关联设计到组合主键,
那么应该使用<literal>@FieldResult</literal>注解来定义每个外键列.
- <literal>@FieldResult</literal>的名字由以下几部分组成:
+ <literal>@FieldResult</literal>的名字由以下几部分组成:
定义这种关系的属性名字+"."+主键名或主键列或主键属性.</para>
<programlisting>@Entity
@@ -2007,7 +2038,7 @@
<programlisting><emphasis role="bold">@SqlResultSetMapping(name="scalar", columns=@ColumnResult(name="dimension"))
@NamedNativeQuery(name="scalar", query="select length*width as dimension from SpaceShip", resultSetMapping="scalar")</emphasis></programlisting>
- <para>本地查询中还有另外一个hint属性:
+ <para>本地查询中还有另外一个hint属性:
<literal>org.hibernate.callable</literal>.
这个属性的布尔变量值表明这个查询是否是一个存储过程.</para>
</sect2>
@@ -2070,10 +2101,10 @@
</note>
</para>
- <para>以下是一些附加的Hibernate注解扩展:</para>
+ <para>以下是一些附加的Hibernate注解扩展:</para>
<para><literal>@org.hibernate.annotations.BatchSize</literal>
- 允许你定义批量获取该实体的实例数量(如:<literal>@BatchSize(size=4)</literal>).
+ 允许你定义批量获取该实体的实例数量(如:<literal>@BatchSize(size=4)</literal>).
当加载一特定的实体时,Hibernate将加载在持久上下文中未经初始化的同类型实体,直至批量数量(上限).</para>
<para><literal>@org.hibernate.annotations.Proxy</literal>
@@ -2087,7 +2118,7 @@
定义了在DDL语句中定义的合法性检查约束(该约束为可选).</para>
<para><literal>@OnDelete(action=OnDeleteAction.CASCADE)</literal>
- 定义于被连接的子类(joined subclass):在删除时使用SQL级连删除,而非通常的Hibernate删除机制.</para>
+ 定义于被连接的子类(joined subclass):在删除时使用SQL级连删除,而非通常的Hibernate删除机制.</para>
<para><literal>@Table(name="tableName", indexes = {
@Index(name="index1", columnNames={"column1", "column2"} ) } )</literal>
@@ -2102,7 +2133,7 @@
<para>
<literal>@org.hibernate.annotations.Table</literal> 是对
<literal>@javax.persistence.Table</literal>的补充而不是它的替代品.
- 特别是当你打算改变表名的默认值的时候,你必须使用<literal>@javax.persistence.Table</literal>,
+ 特别是当你打算改变表名的默认值的时候,你必须使用<literal>@javax.persistence.Table</literal>,
而不是<literal>@org.hibernate.annotations.Table</literal>.</para>
</note>
@@ -2126,7 +2157,7 @@
public class Carrot extends Vegetable { ... }</programlisting></para>
</sect2>
- <sect2>
+ <sect2 id="entity-hibspec-identifier" label="Identifier" revision="1">
<title>标识符</title>
<para><literal><literal>@org.hibernate.annotations.GenericGenerator</literal>
@@ -2148,9 +2179,20 @@
<para><literal>strategy</literal>可以是Hibernate3生成器策略的简称,
或者是一个<classname>IdentifierGenerator</classname>实现的(带包路径的)全限定类名.
你可以通过<literal>parameters</literal>属性增加一些参数.</para>
-</sect2>
+
+ <para>和标准的对比,<literal>@GenericGenerator</literal>是可用于包一级的注解,
+ 使之成为应用级的生成器(就象在JPA XML文件里面那样).</para>
-<sect2 id="entity-hibspec-property" revision="2">
+ <programlisting>@GenericGenerator(name="hibseq", strategy = "seqhilo",
+ parameters = {
+ @Parameter(name="max_lo", value = "5"),
+ @Parameter(name="sequence", value="heybabyhey")
+ }
+)
+package org.hibernate.test.model</programlisting>
+ </sect2>
+
+ <sect2 id="entity-hibspec-property" revision="2">
<title>属性</title>
<sect3>
@@ -2160,7 +2202,7 @@
在实体继承层次中所处的位置推演而得的.子实体(Sub-entities),
内嵌对象和被映射的父类均继承了根实体(root entity)的访问类型.</para>
- <para>在Hibernate中,你可以把访问类型覆盖成:</para>
+ <para>在Hibernate中,你可以把访问类型覆盖成:</para>
<itemizedlist>
<listitem>
@@ -2172,7 +2214,7 @@
</listitem>
</itemizedlist>
- <para>为支持这种行为,Hibernate引入了(a)xn--accesstype-mh3wx75w.xn--:-mo6ash2wa05es6hi4g0mj20k03ao76zh0bjz6gk65a</para>
+ <para>为支持这种行为,Hibernate引入了(a)xn--accesstype-mh3wx75w.xn--ghqtfqsa72dv4gyqgmtieyjb1aw92xrvblz5g213a:</para>
<itemizedlist>
<listitem>
@@ -2198,12 +2240,12 @@
<para>若访问类型被标以"property",则Hibernate会扫描getter方法的注解,若访问类型被标以"field",
则扫描字段的注解.否则,扫描标为@Id或@embeddedId的元素.</para>
- <para>你可以覆盖某个属性(property)的访问类型,但是受注解的元素将不受影响:
+ <para>你可以覆盖某个属性(property)的访问类型,但是受注解的元素将不受影响:
例如一个具有field访问类型的实体,(我们)可以将某个字段标注为 @AccessType("property"),
则该字段的访问类型随之将成为property,但是其他字段上依然需要携带注解.</para>
<para>若父类或可内嵌的对象没有被注解,则使用根实体的访问类型(即使已经在非直系父类或可内嵌对象上定义了访问类型).
- 此时俄罗斯套娃(Russian doll)原理就不再适用.(译注:俄罗斯套娃(матрёшка或 матрешка)是俄罗斯特产木制玩具,
+ 此时俄罗斯套娃(Russian doll)原理就不再适用.(译注:俄罗斯套娃(матрёшка或 матрешка)是俄罗斯特产木制玩具,
一般由多个一样图案的空心木娃娃一个套一个组成,最多可达十多个,通常为圆柱形,底部平坦可以直立.)</para>
<programlisting>@Entity
@@ -2262,7 +2304,7 @@
<title>类型</title>
<para><literal>@org.hibernate.annotations.Type</literal>
- 覆盖了Hibernate所用的默认类型:这通常不是必须的,因为类型可以由Hibernate正确推得.
+ 覆盖了Hibernate所用的默认类型:这通常不是必须的,因为类型可以由Hibernate正确推得.
关于Hibernate类型的详细信息,请参考Hibernate使用手册.</para>
<para><literal>@org.hibernate.annotations.TypeDef</literal> 和
@@ -2375,21 +2417,27 @@
</sect2>
- <sect2>
+ <sect2 id="entity-hibspec-inheritance" revision="1">
<title>继承</title>
<para>SINGLE_TABLE 是个功能强大的策略,但有时,特别对遗留系统而言,
是无法加入一个额外的辨别符列.
- 由此,Hibernate引入了辨别符公式(discriminator formula)的概念:
+ 由此,Hibernate引入了辨别符公式(discriminator formula)的概念:
<literal>@DiscriminatorFormula</literal>是<literal>@DiscriminatorColumn</literal>的替代品,
它使用SQL片段作为辨别符解决方案的公式( 不需要有一个专门的字段).</para>
<programlisting>@Entity
@DiscriminatorForumla("case when forest_type is null then 0 else forest_type end")
public class Forest { ... }</programlisting>
+
+ <para>默认情况下查询顶级实体,Hibernate不会加入带鉴别器列的约束条件子句.
+ 但是如果该列中还包含了和继承层次无关的值(通过<literal>@DiscriminatorValue</literal>)
+ 就会很不方便.为了解决这个问题,你可以在类上使用<literal>@ForceDiscriminator</literal>注解
+ (将该注解放在<literal>@DiscriminatorColumn</literal>后面).
+ 这样Hibernate在加载实体的时候就可以列出对应的值.</para>
</sect2>
- <sect2>
+ <sect2 id="entity-hibspec-singleassoc">
<title>关于单个关联关系的注解</title>
<para>默认情况下,当预期的被关联元素不在数据库中(关乎关联列的错误id),致使Hiberante无法解决关联性问题时,Hibernate就会抛出异常.
@@ -2421,6 +2469,20 @@
<para>上面这个例子中,Hibernate将生成一个数据库级的级联删除约束.</para>
+ <para>Hibernate生成的外键约束的名字可读性相当差,
+ 你可以使用<literal>@ForeignKey</literal>注解覆盖自动生成的值.</para>
+
+ <programlisting>@Entity
+public class Child {
+ ...
+ @ManyToOne
+ <emphasis role="bold">@ForeignKey(name="FK_PARENT")</emphasis>
+ public Parent getParent() { ... }
+ ...
+}
+
+alter table Child add constraint FK_PARENT foreign key (parent_id) references Parent</programlisting>
+
<sect3>
<title>延迟选项和获取模式</title>
@@ -2523,8 +2585,8 @@
<sect2 id="entity-hibspec-collection" revision="2">
<title>关于集合类型的注解</title>
- <sect3>
- <title>参数注解</title>
+ <sect3 id="entity-hibspec-collection-enhance" revision="2">
+ <title>增强集合设置</title>
<para>以下是可能的设置方式<itemizedlist>
<listitem>
@@ -2532,7 +2594,8 @@
</listitem>
<listitem>
- 用@Where注解设置Where子句
+ 用@Where或@WhereJoinTable注解设置Where子句,
+ 这两种注解分别应用于目标实体和关联表
</listitem>
<listitem>
@@ -2550,7 +2613,9 @@
<para>你也可以利用<literal>@Sort</literal>注解定义一个排序比较器(sort comparator),
表明希望的比较器类型,无序、自然顺序或自定义排序,三者择一.若你想用你自己实现的comparator,
- 你还需要利用<literal>comparator</literal>属性(attribute)指明实现类.</para>
+ 你还需要利用<literal>comparator</literal>属性(attribute)指明实现类.
+ 注意你需要使用<classname>SortedSet</classname>或<classname>SortedMap</classname>接口
+ </para>
<programlisting> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="CUST_ID")
@@ -2562,42 +2627,158 @@
}</programlisting>
<para>关于这些注解更详细的信息,请参阅此前的描述.</para>
+
+ <para>Hibernate生成的外键约束的名字可读性相当差,
+ 你可以使用<literal>@ForeignKey</literal>注解覆盖自动生成的值.
+ 注意该注解应该置于关联关系的主体端,<literal>inverseName</literal>
+ 指向另一端的约束.
+ </para>
+ <programlisting>@Entity
+public class Woman {
+ ...
+ @ManyToMany(cascade = {CascadeType.ALL})
+ <emphasis role="bold">@ForeignKey(name = "TO_WOMAN_FK", inverseName = "TO_MAN_FK")</emphasis>
+ public Set<Man> getMens() {
+ return mens;
+ }
+}
+
+alter table Man_Woman add constraint TO_WOMAN_FK foreign key (woman_id) references Woman
+alter table Man_Woman add constraint TO_MAN_FK foreign key (man_id) references Man
+ </programlisting>
+
</sect3>
- <sect3>
+ <sect3 id="entity-hibspec-collection-extratype" revision="1">
<title>更多的集合类型</title>
+
+ <sect4>
+ <title>List</title>
- <para>比EJB3更胜一筹的是,Hibernate Annotations支持真正的
+ <para>比EJB3更胜一筹的是,Hibernate Annotations支持真正的
<classname>List</classname>和<classname>Array</classname>.
映射集合的方式和以前完全一样,只不过要新增<literal>@IndexColumn</literal>注解.
该注解允许你指明存放索引值的字段.你还可以定义代表数据库中首个元素的索引值(亦称为索引基数).
常见取值为<literal>0</literal>或<literal>1</literal>.</para>
- <programlisting>@OneToMany(cascade = CascadeType.ALL)
+ <programlisting>@OneToMany(cascade = CascadeType.ALL)
@IndexColumn(name = "drawer_position", base=1)
public List<Drawer> getDrawers() {
return drawers;
}</programlisting>
- <note>
- <para>假如你忘了设置<literal>@IndexColumn</literal>,
- Hibernate会采用包(bag)语义(译注:即允许重复元素的无序集合).</para>
- </note>
+ <note>
+ <para>假如你忘了设置<literal>@IndexColumn</literal>,
+ Hibernate会采用bag语义(译注:即允许重复元素的无序集合).
+ 如果你既想使用bag语义,但是又不希望受制于其约束语义,
+ 可以考虑使用<literal>@CollectionId</literal>注解.
+ </para>
+ </note>
+ </sect4>
- <para>Hibernate注解支持true Map映射,
- 如果没有设置<literal>@javax.persistence.MapKey</literal>,
- hibernate将key元素或嵌入式对象直接映射到他们所属的列.
- 要覆写默认的列,可以使用以下注解:
- <literal>@org.hibernate.annotations.MapKey</literal>适用的key为基本类型或者嵌入式对象,
- <literal>@org.hibernate.annotations.MapKey</literal>适用的key为实体.
- </para>
+ <sect4>
+ <title>Map</title>
+
+ <para>Hibernate注解支持true Map映射,
+ 如果没有设置<literal>@javax.persistence.MapKey</literal>,
+ hibernate将key元素或嵌入式对象直接映射到他们所属的列.
+ 要覆写默认的列,可以使用以下注解:
+ <literal>@org.hibernate.annotations.MapKey</literal>适用的key为基本类型
+ (默认为<literal>mapkey</literal>)或者嵌入式对象,
+ <literal>@org.hibernate.annotations.MapKey</literal>适用的key为实体.
+ </para>
+ </sect4>
+
+ <sect4 id="entity-hibspec-collection-extratype-indexbidir">
+ <title>带索引集合的双向关联</title>
+
+ <para>双向关联的其中一端在使用<literal>@IndexColumn</literal>或者
+ <literal>@org.hibernate.annotations.MapKey[ManyToMany]</literal>注解
+ 需要考虑一些特殊的因素.如果子类存在某个属性映射到索引列,这种情况下是没有问题的,我们可以
+ 继续在集合映射的时候使用<literal>mappedBy</literal>,如下:</para>
+
+ <programlisting>@Entity
+public class Parent {
+ @OneToMany(mappedBy="parent")
+ @org.hibernate.annotations.MapKey(columns=@Column(name="name"))
+ private Map<String, Child> children;
+ ...
+}
+
+@Entity
+public class Parent {
+ ...
+ @Basic
+ private String name;
+
+ @ManyToOne
+ @JoinColumn(name="parent_id", nullable=false)
+ private Parent parent;
+ ...
+}</programlisting>
+
+ <para>但是,如果在子类中没有该属性,我们就不能认为这种关联是真正的双向关联
+ (也就是在关联的一端有信息而另一端没有).因此在这种情况下,我们就不能使用
+ <literal>mappedBy</literal>将其映射集合.取而代之为下面这种映射方式:</para>
+
+ <programlisting>@Entity
+public class Parent {
+ @OneToMany
+ @org.hibernate.annotations.MapKey(columns=@Column(name="name"))
+ @JoinColumn(name="parent_id", nullable=false)
+ private Map<String, Child> children;
+ ...
+}
+
+@Entity
+public class Parent {
+ ...
+ @ManyToOne
+ @JoinColumn(name="parent_id", insertable=false, updatable=false, nullable=false)
+ private Parent parent;
+ ...
+}</programlisting>
+
+ <para>注意在上面的映射中,关联的集合端负责更新外键.</para>
+ </sect4>
+
+ <sect4>
+ <title>带主键的包</title>
+
+ <para>另外一个有趣的特征就是可以给bag集合定义一个代理主键.通过这种方式
+ 优雅的去除了bag的缺点:update和remove操作更加有效率,每次查询或每个实体可以
+ 超过一个<literal>EAGER</literal> bag.该主键被保存在集合表的一个附加列,
+ 该列对于Java应用不可见.@CollectionId注解将一个集合标注为id bag,同时还
+ 可以覆写主键列,主键类型以及生成器策略.生成器策略可以是<literal>identity</literal>,
+ 也可以是应用中任何已定义的生成器的名字.</para>
+
+ <programlisting>@Entity
+@TableGenerator(name="ids_generator", table="IDS")
+public class Passport {
+ ...
+
+ @ManyToMany(cascade = CascadeType.ALL)
+ @JoinTable(name="PASSPORT_VISASTAMP")
+ <emphasis role="bold">@CollectionId(
+ columns = @Column(name="COLLECTION_ID"),
+ type=@Type(type="long"),
+ generator = "ids_generator"
+ )</emphasis>
+ private Collection<Stamp> visaStamp = new ArrayList();
+ ...
+}</programlisting>
+ </sect4>
+
+ <sect4>
+ <title>元素或组合元素的集合</title>
+
<para>Hibernate Annotations还支持核心类型集合(Integer, String, Enums, ......)、
可内嵌对象的集合,甚至基本类型数组.这就是所谓的元素集合.</para>
<para>元素集合可用@CollectionOfElements来注解(作为@OneToMany的替代).
- 为了定义集合表(译注:即存放集合元素的表,与下面提到的主表对应),要在关联属性上使用@JoinTable注解,
+ 为了定义集合表(译注:即存放集合元素的表,与下面提到的主表对应),要在关联属性上使用@JoinTable注解,
joinColumns定义了介乎实体主表与集合表之间的连接字段(inverseJoincolumn是无效的且其值应为空).
对于核心类型的集合或基本类型数组,你可以在关联属性上用<literal>@Column</literal>来覆盖存放元素值的字段的定义.
你还可以用<literal>@AttributeOverride</literal>来覆盖存放可内嵌对象的字段的定义.
@@ -2718,6 +2899,7 @@
用<literal>@OneToMany</literal>来标识集合元素的这种旧有方式目前尚有效,
但是不推荐使用,而且在以后的发布版本中不再支持这种方式.</para>
</note>
+ </sect4>
</sect3>
</sect2>
@@ -2764,11 +2946,11 @@
</callout>
<callout arearefs="hm2">
- <para>region (可选的):缓存范围(默认为类的全限定类名或是集合的全限定角色名)</para>
+ <para>region (可选的):缓存范围(默认为类的全限定类名或是集合的全限定角色名)</para>
</callout>
<callout arearefs="hm3">
- <para><literal>include</literal> (可选的):值为all时包括了所有的属性(proterty),
+ <para><literal>include</literal> (可选的):值为all时包括了所有的属性(proterty),
为non-lazy时仅含非延迟属性(默认值为all)</para>
</callout>
</calloutlist>
@@ -2776,16 +2958,17 @@
</programlistingco>
</sect2>
- <sect2>
+ <sect2 id="entity-hibspec-filters">
<title>过滤器</title>
- <para>Hibernate具有数据过滤器的概念,可在运行期应用于一个给定的session.过滤器需要事先定义好.</para>
+ <para>Hibernate具有在数据上应用任意过滤器的能力,可在运行期应用于一个给定的session.过滤器需要事先定义好.</para>
<para><literal>@org.hibernate.annotations.FilterDef</literal> 或
<literal>@FilterDefs</literal> 定义过滤器声明,为同名过滤器所用.
- 过滤器声明带有一个name()和一个parameters()数组,<literal>@ParamDef</literal>包含name和type,
- 你还可以为给定的<literal>@filterDef</literal>定义一个defaultCondition()参数,
- 当<literal>@Filter</literal>中没有任何定义时,可使用该参数定义缺省条件.
+ 过滤器声明带有一个name()和一个parameters()数组. 参数提供了在运行时调整
+ 过滤器行为的能力,过滤器通过<literal>@ParamDef</literal>注解定义,该注解包含name和type,
+ 你还可以为给定的<literal>@FilterDef</literal>定义一个defaultCondition()参数,
+ 当所有的<literal>@Filter</literal>中没有任何定义时,可使用该参数定义缺省条件.
<literal>@FilterDef</literal> (s)可以在类或包一级进行定义.</para>
<para>现在我们来定义应用于实体或集合加载时的SQL过滤器子句.我们使用<literal>@Filter</literal>,并将其置于实体或集合元素上.</para>
@@ -2797,10 +2980,21 @@
@Filter(name="minLength", condition=":minLength <= length")
} )
public class Forest { ... }</programlisting></para>
+
+ <para>当这些集合使用关联表来表示关系的时候,你可能需要对于关联表或者目标实体表应用
+ 过滤条件.使用<literal>@Filter</literal>注解可以在目标实体上添加改类约束.
+ 但是如果你打算在关联表上使用,就需要使用<literal>@FilterJoinTable</literal>注解.</para>
+
+ <programlisting> @OneToMany
+ @JoinTable
+ //filter on the target entity table
+ @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length")
+ //filter on the association table
+ @FilterJoinTable(name="security", condition=":userlevel >= requredLevel")
+ public Set<Forest> getForests() { ... }</programlisting>
</sect2>
-
- <sect2>
+ <sect2 id="entity-hibspec-query">
<title>查询</title>
<para>由于Hibernate引入了
@@ -2849,8 +3043,10 @@
</listitem>
</itemizedlist>
- <para>注意,EJB3已公开的最终草案中引入了<literal>@QueryHint</literal>的概念,
- 这可能是定义hints更好的方法.</para>
+ <para>通过<literal>@QueryHint</literal>注解可以在
+ <literal>@javax.persistence.NamedQuery</literal>
+ 中设置hints.另一个重要的优势是可以将这些注解应用到包上.</para>
+
</sect2>
</sect1>
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/lucene.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/lucene.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/lucene.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<chapter id="lucene">
- <title id="lucene">Hibernate与Lucene集成</title>
+<chapter id="lucene" revision="1">
+ <title>Hibernate与Lucene集成</title>
- <para>Lucene是一个高性能的java搜索引擎库,可以从 Apache软件基金组织获取。
- Hibernate Annotations包括一个注解包,它允许把任何域模型对象标记为可索引的,
- 并且对任何经由Hibernate进行持续化的实例,Hibernate 都会为之维护一个对应的Lucene索引。</para>
+ <para>Lucene是一个高性能的java搜索引擎库,可以从 Apache软件基金组织获取.
+ Hibernate Annotations包括一个注解包,它允许把任何域模型对象标记为可索引的,
+ 并且对任何经由Hibernate进行持续化的实例,Hibernate 都会为之维护一个对应的Lucene索引.</para>
- <sect1 id="lucene-intro">
- <title>使用Lucene为实体建立索引</title>
+ <para>Hibernate Lucene目前尚在进行中,新的特征也正在酝酿之中.因此后续版本将会有一些向前兼容的修改.</para>
- <sect2>
- <title>注解领域模型</title>
+ <section id="lucene-mapping">
+ <title>将实体映射到索引</title>
- <para>首先,必须将一个持久类声明为
- <literal>@Indexed</literal>:</para>
+ <para>首先,通过在类上标注<literal>@Indexed</literal>注解将一个持久类声明可索引化的类:</para>
<programlisting>@Entity
@Indexed(index="indexes/essays")
@@ -21,13 +19,14 @@
...
}</programlisting>
- <para>属性<literal>index</literal>是告诉Hibernate, Lucene索引信息所在的位置(你文件系统的某个目录)。
- 如果你想为所有的Lucene索引定义一个根目录,你可以在配置文件中用属性<literal>hibernate.lucene.index_dir</literal>进行配置。
+ <para>属性<literal>index</literal>是告诉Hibernate, Lucene的索引目录名(你文件系统的某个目录).
+ 如果你想为所有的Lucene索引定义一个根目录,你可以在配置文件中用属性
+ <literal>hibernate.lucene.default.indexDir</literal>进行配置.
</para>
- <para>Lucene索引包括四种字段:<emphasis>keyword</emphasis> 字段,<emphasis>text</emphasis>
- 字段,<emphasis>unstored</emphasis>字段和<emphasis>unindexed</emphasis>字段。
- Hibernate注解提供了将实体属性标记为前三种被索引字段的注解。</para>
+ <para>Lucene索引包括四种字段:<emphasis>keyword</emphasis> 字段,<emphasis>text</emphasis>
+ 字段,<emphasis>unstored</emphasis>字段和<emphasis>unindexed</emphasis>字段.
+ Hibernate注解提供了将实体属性标记为前三种被索引字段的注解.</para>
<programlisting>@Entity
@Indexed(index="indexes/essays")
@@ -48,22 +47,110 @@
}</programlisting>
<para>这些注解定义了一个带有三个字段的索引:
- <literal>Id</literal>, <literal>Abstract</literal> 和
- <literal>Text</literal>.</para>
-
+ <literal>id</literal>, <literal>Abstract</literal> and
+ <literal>text</literal>.
+ 注意这些字段的第一个字母小写,字段的命名应遵守JavaBean命名规范.
+ </para>
+
<para>注意:你必须在你的实体类的标志属性上指定
<literal>@Keyword(id=true)</literal> .</para>
+
+ <para>Lucene具有<emphasis>boost factor</emphasis>的概念.
+ 在建索引的过程中,对于一个字段或一个索引元素给予更高的权重(相对其他字段或元素),
+ 你可以在类和字段上使用<literal>@Boost</literal>注解.</para>
+
+ <para>用于对元素建立索引的分析器类是可以通过<literal>hibernate.lucene.analyzer</literal>属性进行配置的.
+ 如果没有定义,则把 <classname>org.apache.lucene.analysis.standard.StandardAnalyzer</classname>作为缺省.</para>
- <para>用于对元素建立索引的分析器类是可以通过<literal>hibernate.lucene.analyzer</literal>属性进行配置的。
- 如果没有定义,则把 <classname>org.apache.lucene.analysis.standard.StandardAnalyzer</classname>作为缺省。</para>
+ </section>
- </sect2>
+ <section id="lucene-configuration">
+ <title>配置</title>
- <sect2>
+ <section id="lucene-configuration-directory">
+ <title>目录配置</title>
+
+ <para>Lucene中具有存储索引的目录的概念.这些目录实现是可以定制的,
+ 而Lucene默认自带了一个文件系统实现以及一个完全内存实现.
+ 而Hibernate Lucene提供了<literal>DirectoryProvider</literal>,
+ 据此配置并初始化Lucence目录.</para>
+
+ <table>
+ <title>内置Directory Provider列表</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry align="center">Class</entry>
+
+ <entry align="center">description</entry>
+
+ <entry align="center">Properties</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>org.hibernate.lucene.store.FSDirectoryProvider</entry>
+
+ <entry>基于文件系统的目录.用法为
+ <indexBase>/<<literal>@Index.name</literal>></entry>
+
+ <entry><literal>indexBase</literal>: 基础目录</entry>
+ </row>
+
+ <row>
+ <entry>org.hibernate.lucene.store.RAMDirectoryProvider</entry>
+
+ <entry>基于内存的目录,可通过<literal>@Index.name</literal>元素唯一标识一个目录</entry>
+
+ <entry>none</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>如果内置的directory providers无法满足你的需要,你可以通过实现
+ <classname>org.hibernate.store.DirectoryProvider</classname>接口
+ 提供自己的directory provider.</para>
+
+ <para>每一个索引实体都和Lucene索引关联(一个索引可以在多个实体间共享,但是这种情况很少见).
+ 你可以使用前缀为<literal><literal>hibernate.lucene.<indexname></literal></literal>
+ 的索引进行配置.
+ 所有的索引都会继承默认的属性,该属性的前缀为hibernate.lucene.default.</para>
+
+ <para>定义指定索引的directory provider,可使用
+ <literal>hibernate.lucene.<indexname>.directory_provider</literal></para>
+
+ <programlisting>hibernate.lucene.default.directory_provider org.hibernate.lucene.store.FSDirectoryProvider
+hibernate.lucene.default.indexDir=/usr/lucene/indexes
+
+hibernate.lucene.Rules.directory_provider org.hibernate.lucene.store.RAMDirectoryProvider
+</programlisting>
+
+ <para>applied on</para>
+
+ <programlisting>@Indexed(name="Status")
+public class Status { ... }
+
+@Indexed(name="Rules")
+public class Rule { ... }</programlisting>
+
+ <para>将会在<filename>/usr/lucene/indexes/Status</filename>之下创建一个文件系统目录,
+ 该目录下保存了所有的Status实体索引,而名为<literal>Rules</literal>
+ 的内存目录下则保存了所有的Rule实体索引.</para>
+
+ <para>因此你可以很轻松的定义通用的规则,例如directory provider和base directory,
+ 并在以后覆盖每一个基础索引(index basis)的默认值.</para>
+
+ <para>自定义的DirectoryProvider可以享受同样的配置机制.</para>
+ </section>
+
+ <section id="lucene-configuration-event">
<title>启用自动索引</title>
- <para>我们激活用于帧听三类Hibernate事件的 <literal>LuceneEventListener</literal>,
- 这些事件会在变更被提交至数据库后产生。</para>
+ <para>我们激活用于帧听三类Hibernate事件的 <literal>LuceneEventListener</literal>,
+ 这些事件会在变更被提交至数据库后产生.</para>
<programlisting><hibernate-configuration>
...
@@ -80,7 +167,7 @@
class="org.hibernate.lucene.event.LuceneEventListener"/>
</event>
</hibernate-configuration></programlisting>
- </sect2>
- </sect1>
+ </section>
+ </section>
</chapter>
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/setup.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/setup.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/setup.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -7,21 +7,21 @@
<itemizedlist>
<listitem>
- <para>首先从Hibernate官方网站下载并解压Hibernate Annotations的发布包。</para>
+ <para>首先从Hibernate官方网站下载并解压Hibernate Annotations的发布包.</para>
</listitem>
<listitem>
- <para><emphasis>这个版本(预览版)要求使用Hibernate 3.2.0.CR2或更高版本。请不要和老版本的Hibernate 3.x混合起来使用。</emphasis></para>
+ <para><emphasis>这个版本要求使用Hibernate 3.2.0.GA或更高版本.请不要和老版本的Hibernate 3.x混合起来使用.</emphasis></para>
</listitem>
<listitem>
- <para>这个版本在Hibernate core 3.2.0.CR2的基础上工作良好。</para>
+ <para>这个版本在Hibernate core 3.2.0.CR5和3.2.0.GA的基础上工作良好.</para>
</listitem>
<listitem>
- <para>首先确定你已经安装了JDK 5.0。当然就算使用低版本的JDK,
- Xdoclet也可以提供(基于注解的)元数据所带来的部分功能。
- 不过请注意本文档只描述跟JDK5.0注解有关的内容,关于Xdoclet请参考相关文档。</para>
+ <para>首先确定你已经安装了JDK 5.0.当然就算使用低版本的JDK,
+ Xdoclet也可以提供(基于注解的)元数据所带来的部分功能.
+ 不过请注意本文档只描述跟JDK5.0注解有关的内容,关于Xdoclet请参考相关文档.</para>
</listitem>
</itemizedlist>
</section>
@@ -29,24 +29,24 @@
<section id="setup-configuration">
<title>系统配置</title>
- <para>首先就是设置classpath(当然是在IDE中创建了一个新项目之后)。 <itemizedlist>
+ <para>首先就是设置classpath(当然是在IDE中创建了一个新项目之后). <itemizedlist>
<listitem>
- <para>将Hibernate3核心文件以及其依赖的第三方库文件(请参考lib/README.txt文件)加入到你的classpath里面。</para>
+ <para>将Hibernate3核心文件以及其依赖的第三方库文件(请参考lib/README.txt文件)加入到你的classpath里面.</para>
</listitem>
<listitem>
<para>将<filename>hibernate-annotations.jar</filename>
- 和<filename>lib/ejb3-persistence.jar</filename>加入到你的classpath里面。</para>
+ 和<filename>lib/ejb3-persistence.jar</filename>加入到你的classpath里面.</para>
</listitem>
<listitem>
- <para>如果要使用 <xref linkend="lucene" />,还需要将lucene的jar文件加入你的classpath。</para>
+ <para>如果要使用 <xref linkend="lucene" />,还需要将lucene的jar文件加入你的classpath.</para>
</listitem>
</itemizedlist></para>
<para>我们推荐在一个包装器(wrapper)类<classname>HibernateUtil</classname>
- 的静态初始化代码块中启动Hibernate。或许你在Hibernate文档的其他很多地方看到过这个类,
- 但是要在你的项目中使用注解,还需要对这个辅助(helper)类进行扩展。扩展如下:
+ 的静态初始化代码块中启动Hibernate.或许你在Hibernate文档的其他很多地方看到过这个类,
+ 但是要在你的项目中使用注解,还需要对这个辅助(helper)类进行扩展.扩展如下:
<programlisting>package hello;
import org.hibernate.*;
@@ -75,8 +75,8 @@
}
</programlisting></para>
- <para>这里比较有意思的是使用到了<classname>AnnotationConfiguration</classname>类。
- 在XML配置文件(通常是<filename>hibernate.cfg.xml</filename>)中则定义了包和经过注解的类。下面的xml和前面的声明等价:
+ <para>这里比较有意思的是使用到了<classname>AnnotationConfiguration</classname>类.
+ 在XML配置文件(通常是<filename>hibernate.cfg.xml</filename>)中则定义了包和经过注解的类.下面的xml和前面的声明等价:
</para>
<programlisting><!DOCTYPE hibernate-configuration PUBLIC
@@ -95,7 +95,7 @@
</hibernate-configuration>
</programlisting>
- <para>注意现在你可以混合使用hbm.xml和注解。资源元素(resource element)可以是hbm文件也可以是EJB3 XML发布描述符,此差别对于配置过程是透明的。</para>
+ <para>注意现在你可以混合使用hbm.xml和注解.资源元素(resource element)可以是hbm文件也可以是EJB3 XML发布描述符,此差别对于配置过程是透明的.</para>
<para>除了上面的方式,你还可以通过编程的方式定义包括注解的类和包</para>
@@ -107,23 +107,23 @@
.addAnnotatedClass(Dog.class)</emphasis>
.buildSessionFactory();</programlisting>
- <para>你也可以使用Hibernate Entity Manager来完成以上功能。Hibernate Entity Manager有自己的一套配置机制,详情请参考相关文档。</para>
+ <para>你也可以使用Hibernate Entity Manager来完成以上功能.Hibernate Entity Manager有自己的一套配置机制,详情请参考相关文档.</para>
- <para>除了启动方式和配置文件有所改变之外,结合注解来使用Hibernate API和以前没有什么区别,
- 在其他方面你还是可以继续保持以前的习惯和喜好(<filename>hibernate.properties</filename>,
- <filename>hibernate.cfg.xml</filename>, programmatic APIs等等)。
- 甚至对于同一个<classname>SessionFactory</classname>,你都可以混合带注解的持久类以及传统的bm.cfg.xml声明方式。
- 然而你不能多次声明同一个类(要么通过注解要么通过hbm.xml配置文件),
- 而且在一个映射实体的类继承层次中,这两个配置策略不能同时使用.
+ <para>除了启动方式和配置文件有所改变之外,结合注解来使用Hibernate API和以前没有什么区别,
+ 在其他方面你还是可以继续保持以前的习惯和喜好(<filename>hibernate.properties</filename>,
+ <filename>hibernate.cfg.xml</filename>, programmatic APIs等等).
+ 甚至对于同一个<classname>SessionFactory</classname>,你都可以混合带注解的持久类以及传统的bm.cfg.xml声明方式.
+ 然而你不能多次声明同一个类(要么通过注解要么通过hbm.xml配置文件),
+ 而且在一个映射实体的类继承层次中,这两个配置策略不能同时使用.
</para>
- <para>为了简化从hbm文件到注解的迁移过程,
- 配置机制将自动检测在注解和hbm文件中重复的映射。
- 默认情况下hbm文件中的声明比类中的注解元数据具有更高的优先级。
- 这种优先级的设定是以类为单位的。
- 你也可以通过<literal>hibernate.mapping.precedence</literal>修改这种优先级。
- 默认的值是<literal>hbm, class</literal>,
- 如果改为<literal>class,hbm</literal>,当发生冲突的时候,类中的注解将比hbm文件具有更高的优先级。
+ <para>为了简化从hbm文件到注解的迁移过程,
+ 配置机制将自动检测在注解和hbm文件中重复的映射.
+ 默认情况下hbm文件中的声明比类中的注解元数据具有更高的优先级.
+ 这种优先级的设定是以类为单位的.
+ 你也可以通过<literal>hibernate.mapping.precedence</literal>修改这种优先级.
+ 默认的值是<literal>hbm,class</literal>,
+ 如果改为<literal>class,hbm</literal>,当发生冲突的时候,类中的注解将比hbm文件具有更高的优先级.
</para>
</section>
</chapter>
\ No newline at end of file
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/validator.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/validator.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/validator.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -2,23 +2,23 @@
<chapter id="validator">
<title>Hibernate验证器</title>
- <para>注解是一种为领域模型(domain model)指定不变约束的简洁而幽雅的方法。例如,你能
- 表示一个属性永远不为null,一个帐户余额一定是正值,等等。这些域模型约束通过为bean中的属性添加
- 注解来加以声明。随后一个验证器(validator)会读取并检查这些约束。验证机制可以执行于应用程序中的
- 不同层(表现层、数据访问层),而不必复述任何(前述)这些规则。Hibernate验证器正为这一目的而设计的。</para>
+ <para>注解是一种为领域模型(domain model)指定不变约束的简洁而幽雅的方法.例如,你能
+ 表示一个属性永远不为null,一个帐户余额一定是正值,等等.这些域模型约束通过为bean中的属性添加
+ 注解来加以声明.随后一个验证器(validator)会读取并检查这些约束.验证机制可以执行于应用程序中的
+ 不同层(表现层、数据访问层),而不必复述任何(前述)这些规则.Hibernate验证器正为这一目的而设计的.</para>
- <para>Hibernate验证器工作在两个层次上。第一层,它能检查内存中一个类的实例是否违反约束。
- 第二层,它能将约束应用于Hibernate元模型上,并将它们融入生成的数据库schema中。</para>
+ <para>Hibernate验证器工作在两个层次上.第一层,它能检查内存中一个类的实例是否违反约束.
+ 第二层,它能将约束应用于Hibernate元模型上,并将它们融入生成的数据库schema中.</para>
- <para>每个约束注解(constraint annotation)和一个验证器实现关联,该验证器负责检查位于实体实例上的约束。
- 一个验证器也能(可选地)将约束应用于Hibernate元模型上,让Hibernate生成表示这一约束的DDL。使用合适的事件监听器,你能
- 让Hibernate在插入和更新时执行检查操作。Hibernate验证器并不局限于同Hibernate一起使用。
- 你能在你应用程序的任何地方方便地使用它。</para>
+ <para>每个约束注解(constraint annotation)和一个验证器实现关联,该验证器负责检查位于实体实例上的约束.
+ 一个验证器也能(可选地)将约束应用于Hibernate元模型上,让Hibernate生成表示这一约束的DDL.使用合适的事件监听器,你能
+ 让Hibernate在插入和更新时执行检查操作.Hibernate验证器并不局限于同Hibernate一起使用.
+ 你能在你应用程序的任何地方方便地使用它.</para>
- <para>在运行时检查实例时,Hibernate验证器返回违反约束的信息,
- 这些信息以一个<classname>InvalidValue</classname>数组的形式返回。
- 除了众多其他信息外,<classname>InvalidValue</classname>包含了一个错误描述消
- 息,该信息可以内嵌与注解相捆绑的参数值(例如长度限制),以及能被提取至ResourceBundle的消息字串。</para>
+ <para>在运行时检查实例时,Hibernate验证器返回违反约束的信息,
+ 这些信息以一个<classname>InvalidValue</classname>数组的形式返回.
+ 除了众多其他信息外,<classname>InvalidValue</classname>包含了一个错误描述消
+ 息,该信息可以内嵌与注解相捆绑的参数值(例如长度限制),以及能被提取至ResourceBundle的消息字串.</para>
<sect1 id="validator-constraints">
<title>约束</title>
@@ -26,14 +26,14 @@
<sect2>
<title>什么是约束?</title>
- <para>约束通过注解表示。一个约束通常有一些用来参数化约束限制的属性。约束应用于带注解的元素。</para>
+ <para>约束通过注解表示.一个约束通常有一些用来参数化约束限制的属性.约束应用于带注解的元素.</para>
</sect2>
<sect2>
<title>内建约束</title>
- <para>Hibernate验证器有些内建约束,这些约束覆盖了大多数的基本数据检查。随后我们会看到,
- 你不必受制于这些内置约束,因为一分钟内就可以写出你自己的约束。</para>
+ <para>Hibernate验证器有些内建约束,这些约束覆盖了大多数的基本数据检查.随后我们会看到,
+ 你不必受制于这些内置约束,因为一分钟内就可以写出你自己的约束.</para>
<table>
<title>内建约束</title>
@@ -171,7 +171,7 @@
<entry>属性 (object)</entry>
- <entry>对关联对象递归的进行验证。如果对象是集合或数组,就递归地验证其元素。如果对象是Map,则递归验证其值元素。</entry>
+ <entry>对关联对象递归的进行验证.如果对象是集合或数组,就递归地验证其元素.如果对象是Map,则递归验证其值元素.</entry>
<entry>无</entry>
</row>
@@ -179,9 +179,9 @@
<row>
<entry>@Email</entry>
- <entry>属性(String)</entry>
+ <entry>属性(String)</entry>
- <entry>检查字符串是否符合有效的email地址规范。</entry>
+ <entry>检查字符串是否符合有效的email地址规范.</entry>
<entry>无</entry>
</row>
@@ -193,21 +193,25 @@
<sect2 id="validator-constraints-error" xreflabel="Error messages">
<title id="validator-constraints-error">错误信息</title>
+
+ <para>Hibernate验证器提供了一组默认的错误提示信息,它们被翻译成多种语言(如果你的语言不在其中,请给
+ 我们寄一个补丁).你可以创建<filename>ValidatorMessages.properties</filename>或
+ <filename>ValidatorMessages_loc.properties</filename>
+ 文件并改变相应的键值,籍此覆盖那些(默认)信息.你甚至可以在写自己的验证器
+ 注解时添加你自己的附加消息集.如果Hibernate无法从你自定制的resourceBundle
+ 或者ValidatorMessage中解析键值,就会使用内置的默认值.</para>
- <para>Hibernate验证器提供了一组默认的错误提示信息,它们被翻译成多种语言(如果你的语言不在其中,请给
- 我们寄一个补丁)。你可以在<filename>org.hibernate.validator.resources.DefaultValidatorMessages.properties</filename>
- 之外创建<filename>ValidatorMessages.properties</filename>或<filename>ValidatorMessages_loc.properties</filename>
- 文件并改变相应的键值,籍此覆盖那些(默认)信息。你甚至可以在写自己的验证器
- 注解时添加你自己的附加消息集。</para>
-
- <para>或者你可以以编程方式检查bean的验证规则并提供相应的<classname>ResourceBundle</classname>。</para>
+ <para>或者你可以以编程方式检查bean的验证规则并提供相应的<classname>ResourceBundle</classname>,
+ 如果你想使用完全不同的内插法,你可以自己实现<literal>org.hibernate.validator.MessageInterpolator</literal>
+ (详情请参考JavaDoc)
+ </para>
</sect2>
<sect2>
<title>编写你自己的约束</title>
- <para>扩展内建约束集是极其方便的。任何约束都包括两部分:约束<emphasis>描述符</emphasis>(注解)
- 和约束<emphasis>验证器</emphasis>(实现类)。下面是一个简单的用户定义描述符:</para>
+ <para>扩展内建约束集是极其方便的.任何约束都包括两部分:约束<emphasis>描述符</emphasis>(注解)
+ 和约束<emphasis>验证器</emphasis>(实现类).下面是一个简单的用户定义描述符:</para>
<programlisting>@ValidatorClass(CapitalizedValidator.class)
@Target(METHOD)
@@ -218,14 +222,14 @@
String message() default "has incorrect capitalization";
}</programlisting>
- <para><literal>type</literal>参数描述属性应该如何被大写。这是一个完全依赖于注解业务(逻辑)的用户
- 参数。</para>
+ <para><literal>type</literal>参数描述属性应该如何被大写.这是一个完全依赖于注解业务(逻辑)的用户
+ 参数.</para>
- <para><literal>message</literal>是用于描述约束违规的默认字符串,它是强制要求的。你可以采取硬编码的方式,
- 或者通过Java ResourceBundle机制将message的部分/全部内容提取至外部文件。一旦发现message中{parameter}字符串,
- 就会在{parameter}这个位置注入相应的参数值(在我们的例子里Capitalization is not {type}会生成 Capitalization is not FIRST),
- 可以将message对应的整个字符串提取至外部文件ValidatorMessages.properties,这也是一种良好实践。
- 见<xref linkend="validator-constraints-error" />。</para>
+ <para><literal>message</literal>是用于描述约束违规的默认字符串,它是强制要求的.你可以采取硬编码的方式,
+ 或者通过Java ResourceBundle机制将message的部分/全部内容提取至外部文件.一旦发现message中{parameter}字符串,
+ 就会在{parameter}这个位置注入相应的参数值(在我们的例子里Capitalization is not {type}会生成 Capitalization is not FIRST),
+ 可以将message对应的整个字符串提取至外部文件ValidatorMessages.properties,这也是一种良好实践.
+ 见<xref linkend="validator-constraints-error" />.</para>
<programlisting>@ValidatorClass(CapitalizedValidator.class)
@Target(METHOD)
@@ -240,15 +244,15 @@
#in ValidatorMessages.properties
validator.capitalized=<literal>Capitalization is not {type}</literal></programlisting>
- <para>如你所见{}符号是递归的。</para>
+ <para>如你所见{}符号是递归的.</para>
- <para>为了将一个描述符连接到它的验证器实现,我们使用<literal>@ValidatorClass</literal>
- 元注解。验证器类参数必须指定一个实现了<literal>Validator<ConstraintAnnotation></literal>
- 的类。</para>
+ <para>为了将一个描述符连接到它的验证器实现,我们使用<literal>@ValidatorClass</literal>
+ 元注解.验证器类参数必须指定一个实现了<literal>Validator<ConstraintAnnotation></literal>
+ 的类.</para>
- <para>我们现在要实现验证器(也就是实现规则检查)。一个验证器实现能检查一个属性的值
- (实现<literal>PropertyConstraint</literal>),并且/或者可以修改hibernate映射元数据
- (实现<literal>PersistentClassConstraint</literal>),籍此表示数据库级的约束。</para>
+ <para>我们现在要实现验证器(也就是实现规则检查).一个验证器实现能检查一个属性的值
+ (实现<literal>PropertyConstraint</literal>),并且/或者可以修改hibernate映射元数据
+ (实现<literal>PersistentClassConstraint</literal>),籍此表示数据库级的约束.</para>
<programlisting>public class CapitalizedValidator
implements Validator<Capitalized>, PropertyConstraint {
@@ -275,16 +279,16 @@
}
}</programlisting>
- <para>如果违反约束,<literal>isValid()</literal>方法将返回false。更多例子请参考内建验证器实现。</para>
+ <para>如果违反约束,<literal>isValid()</literal>方法将返回false.更多例子请参考内建验证器实现.</para>
- <para>至此我们只看到属性级的验证,你还可以写一个Bean级别的验证注解。Bean自身会被传递给验证器,
- 而不是bean的属性实例。只要对bean自身进行注解即可激活验证检查。在单元测试套件中还可以找到一个小例子。</para>
+ <para>至此我们只看到属性级的验证,你还可以写一个Bean级别的验证注解.Bean自身会被传递给验证器,
+ 而不是bean的属性实例.只要对bean自身进行注解即可激活验证检查.在单元测试套件中还可以找到一个小例子.</para>
</sect2>
<sect2>
<title>注解你的领域模型</title>
- <para>既然你现在已经熟悉注解了,那么对语法也应该很清楚了。</para>
+ <para>既然你现在已经熟悉注解了,那么对语法也应该很清楚了.</para>
<programlisting>public class Address {
private String line1;
@@ -342,7 +346,7 @@
}
}</programlisting>
- <para>上面的例子只展示了公共属性验证,你还可以对任何可见度的字段(field)进行注解。</para>
+ <para>上面的例子只展示了公共属性验证,你还可以对任何可见度的字段(field)进行注解.</para>
<programlisting>@MyBeanConstraint(max=45)
public class Dog {
@@ -351,8 +355,8 @@
...
}</programlisting>
- <para>你可以对接口进行注解。Hibernate验证器会检查给定bean所扩展或实现的所有父类和接口,
- 籍以读取相应的验证器注解(信息)。</para>
+ <para>你可以对接口进行注解.Hibernate验证器会检查给定bean所扩展或实现的所有父类和接口,
+ 籍以读取相应的验证器注解(信息).</para>
<programlisting>public interface Named {
@NotNull String getName();
@@ -367,32 +371,32 @@
}</programlisting>
- <para>在验证Dog bean时会检查name属性的有效性(不为null)。</para>
+ <para>在验证Dog bean时会检查name属性的有效性(不为null).</para>
</sect2>
</sect1>
<sect1>
<title>使用验证器框架</title>
- <para>Hibernate验证器旨在实现多层数据验证,我们在一处表示约束(带注解的域模型),然后将其运用于
- 应用程序的不同层。</para>
+ <para>Hibernate验证器旨在实现多层数据验证,我们在一处表示约束(带注解的域模型),然后将其运用于
+ 应用程序的不同层.</para>
<sect2>
<title>数据库schema层次验证</title>
- <para>无须额外手续,Hibernate Annotations会自动将你为实体定义的约束翻译为映射元数据。例如,如果你的实体
- 的一个属性注解为<literal>@NotNull</literal>,在Hibernate生成的DDL schema中这列会被定义为
- <literal>not null</literal>。</para>
+ <para>无须额外手续,Hibernate Annotations会自动将你为实体定义的约束翻译为映射元数据.例如,如果你的实体
+ 的一个属性注解为<literal>@NotNull</literal>,在Hibernate生成的DDL schema中这列会被定义为
+ <literal>not null</literal>.</para>
</sect2>
<sect2>
<title>Hibernate基于事件的验证</title>
- <para>Hibernate验证器有两个内建Hibernate事件监听器。当一个<literal>PreInsertEvent</literal>
- 或<literal>PreUpdateEvent</literal>发生时,监听器会验证该实体实例的所有约束,如有违反会抛出一个异常。
- 基本上,在Hibernate执行任何插入和更新前对象会被检查。这是激活验证过程的最便捷最简单的方法。当遇到约束
- 违规时,事件会引发一个运行时<classname>InvalidStateException</classname>,该异常包含一个描述每个错误的
- <literal>InvalidValue</literal>数组。</para>
+ <para>Hibernate验证器有两个内建Hibernate事件监听器.当一个<literal>PreInsertEvent</literal>
+ 或<literal>PreUpdateEvent</literal>发生时,监听器会验证该实体实例的所有约束,如有违反会抛出一个异常.
+ 基本上,在Hibernate执行任何插入和更新前对象会被检查.这是激活验证过程的最便捷最简单的方法.当遇到约束
+ 违规时,事件会引发一个运行时<classname>InvalidStateException</classname>,该异常包含一个描述每个错误的
+ <literal>InvalidValue</literal>数组.</para>
<programlisting><hibernate-configuration>
...
@@ -407,29 +411,29 @@
</hibernate-configuration></programlisting>
<para><note>
- <para>在使用Hibernate Entity Manager时,Validation框架会被自动激活。如果bean不带验证注解,
- 就不会有性能损失。</para>
+ <para>在使用Hibernate Entity Manager时,Validation框架会被自动激活.如果bean不带验证注解,
+ 就不会有性能损失.</para>
</note></para>
</sect2>
<sect2>
<title>程序级验证</title>
- <para>Hibernate验证器能应用于你应用程序代码中的任何地方。</para>
+ <para>Hibernate验证器能应用于你应用程序代码中的任何地方.</para>
<programlisting>ClassValidator personValidator = new ClassValidator( Person.class );
ClassValidator addressValidator = new ClassValidator( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
InvalidValue[] validationMessages = addressValidator.getInvalidValues(address);</programlisting>
- <para>头两行为执行类检查而准备Hibernate验证器。第一行依赖于嵌入在Hibernate验证器内的错误
- 消息(见<xref linkend="validator-constraints-error" />),第二行为这些消息准备资源包。这些代码只执行一次,
- 并将验证器进行缓存处理,这种方式是一种良好实践。</para>
+ <para>头两行为执行类检查而准备Hibernate验证器.第一行依赖于嵌入在Hibernate验证器内的错误
+ 消息(见<xref linkend="validator-constraints-error" />),第二行为这些消息准备资源包.这些代码只执行一次,
+ 并将验证器进行缓存处理,这种方式是一种良好实践.</para>
- <para>第三行真正验证了<literal>Address</literal>实例并返回一个<literal>InvalidValue</literal>数组。
- 你的应用程序逻辑随后可以对错误做出响应。</para>
+ <para>第三行真正验证了<literal>Address</literal>实例并返回一个<literal>InvalidValue</literal>数组.
+ 你的应用程序逻辑随后可以对错误做出响应.</para>
- <para>除了针对整个bean你还可以对某个特定属性进行检查。这对于一个属性一个属性的用户交互情形或许是有用的。</para>
+ <para>除了针对整个bean你还可以对某个特定属性进行检查.这对于一个属性一个属性的用户交互情形或许是有用的.</para>
<programlisting>ClassValidator addressValidator = new ClassValidator( Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
@@ -443,12 +447,12 @@
<sect2>
<title>验证信息</title>
- <para>作为一个验证信息的载体,hibernate提供了一个<classname>InvalidValue</classname>数组。
- 每个<literal>InvalidValue</literal>有一组,这些方法分别描述相应的个体问题。</para>
+ <para>作为一个验证信息的载体,hibernate提供了一个<classname>InvalidValue</classname>数组.
+ 每个<literal>InvalidValue</literal>有一组,这些方法分别描述相应的个体问题.</para>
- <para><methodname>getBeanClass()</methodname>获取失败的bean类型。</para>
+ <para><methodname>getBeanClass()</methodname>获取失败的bean类型.</para>
- <para><methodname>getBean()</methodname>获取验证失败的实例(如果有的话,当使用
+ <para><methodname>getBean()</methodname>获取验证失败的实例(如果有的话,当使用
<methodname>getPotentianInvalidValues()</methodname>时则不会取到) </para>
<para><methodname>getValue()</methodname>获取验证失败的值</para>
@@ -456,7 +460,7 @@
<para><methodname>getMessage()</methodname>获取合适的国际化错误消息</para>
<para><methodname>getRootBean()</methodname>获取产生问题的根bean实例(在与<literal>@Valid</literal>连用
- 时很有用),如用getPotentianInvalidValues()则返回null。</para>
+ 时很有用),如用getPotentianInvalidValues()则返回null.</para>
<para><literal>getPropertyPath()</literal>获取“问题”属性从根bean开始的带点的路径</para>
</sect2>
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/xml-overriding.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/xml-overriding.xml 2006-11-07 05:58:20 UTC (rev 10744)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/modules/xml-overriding.xml 2006-11-07 06:15:35 UTC (rev 10745)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<chapter id="xml-overriding">
+<chapter id="xml-overriding" label="Overriding metadata through XML">
<title>通过XML覆写元数据</title>
<para>在EJB3中元数据的主要目标是使用注释,但是EJB3规范也提供通过XML部署文件来覆写或者替换元数据注释.
@@ -8,7 +8,7 @@
<para>在测试套件中有一些附加的XML文件的样例.</para>
- <section>
+ <section id="xml-overriding-principles">
<title>原则</title>
<para>XML部署文件结构被设计为直接映射注释结构,所以如果你知道注释的结构,那么使用XML语法是很简单的.</para>
@@ -46,7 +46,7 @@
<para><literal>cascade-persist</literal> 意味着所有注释作为一个 cascade type 都是PERSIST的. 我们推荐你不要使用该特性.</para>
</section>
- <section>
+ <section id="xml-overriding-principles-entity" revision="1">
<title>实体级别的元数据</title>
<para>你也可以在一个给定的实体上定义或者覆写元数据</para>
@@ -129,8 +129,10 @@
如果没有定义并且<literal>@Entity.name</literal>出现了的话,那么就使用该注释(假如metadata complete 没有被设置).</para>
<para>
- 对于metadata complete (参考下面)元素, 你可以定义一个 <literal>access</literal>(<literal>FIELD</literal> 或者 <literal>PROPERTY</literal>(默认值)),
- 对于非metadata complete 元素,使用注释的access type.</para>
+ 对于metadata complete(参考下面)元素, 你可以定义一个 <literal>access</literal>(<literal>FIELD</literal> 或者 <literal>PROPERTY</literal>(默认值)),
+ 对于非metadata complete元素,如果没有定义<literal>access</literal> ,则使用@Id注解的值,
+ 如果定义了<literal>access</literal>,则使用其对应的值.</para>
+
</callout>
<callout arearefs="aa4">
@@ -294,7 +296,7 @@
通过 <literal>id</literal>,
<literal>embedded-id</literal>, <literal>version</literal>,
<literal>embedded</literal> 和 <literal>basic</literal>你可以覆写一个属性,
- 这些元素中的每一个元素都有相应的subelements:<literal>lob</literal>,
+ 这些元素中的每一个元素都有相应的subelements:<literal>lob</literal>,
<literal>temporal</literal>, <literal>enumerated</literal>,
<literal>column</literal>.</para>
18 years, 2 months
Hibernate SVN: r10744 - in trunk/Hibernate3/doc/reference/zh-cn: . modules
by hibernate-commits@lists.jboss.org
Author: caoxg
Date: 2006-11-07 00:58:20 -0500 (Tue, 07 Nov 2006)
New Revision: 10744
Modified:
trunk/Hibernate3/doc/reference/zh-cn/master.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/architecture.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/basic_mapping.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/batch.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/configuration.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/filters.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/performance.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/persistent_classes.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/query_hql.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/query_sql.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/session_api.xml
trunk/Hibernate3/doc/reference/zh-cn/modules/tutorial.xml
Log:
version 3.2 of Reference Chinese Version
Modified: trunk/Hibernate3/doc/reference/zh-cn/master.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/master.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/master.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -35,7 +35,7 @@
<title>HIBERNATE - 符合Java习惯的关系数据库持久化</title>
<subtitle>Hibernate参考文档</subtitle>
- <releaseinfo>3.1.2</releaseinfo>
+ <releaseinfo>3.2</releaseinfo>
</bookinfo>
<toc/>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/architecture.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/architecture.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/architecture.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -235,7 +235,7 @@
请注意,Hibernate对JCA的支持,仍处于实验性阶段。
</para>
</sect1>
- <sect1 id="architecture-current-session" revision="1">
+ <sect1 id="architecture-current-session" revision="2">
<title>上下文相关的(Contextual)Session</title>
<para>
使用Hibernate的大多数应用程序需要某种形式的“上下文相关的” session,特定的session在整个特定的上下文范围内始终有效。然而,对不同类型的应用程序而言,要为什么是组成这种“上下文”下一个定义通常是困难的;不同的上下文对“当前”这个概念定义了不同的范围。在3.0版本之前,使用Hibernate的程序要么采用自行编写的基于<literal>ThreadLocal</literal>的上下文session,要么采用<literal>HibernateUtil</literal>这样的辅助类,要么采用第三方框架(比如Spring或Pico),它们提供了基于代理(proxy)或者基于拦截器(interception)的上下文相关session。
@@ -247,7 +247,7 @@
更好的是,从3.1开始,<literal>SessionFactory.getCurrentSession()</literal>的后台实现是可拔插的。因此,我们引入了新的扩展接口(<literal>org.hibernate.context.CurrentSessionContext</literal>)和新的配置参数(<literal>hibernate.current_session_context_class</literal>),以便对什么是“当前session”的范围和上下文(scope and context)的定义进行拔插。
</para>
<para>
- 请参阅<literal>org.hibernate.context.CurrentSessionContext</literal>接口的Javadoc,那里有关于它的契约的详细讨论。它定义了单一的方法,<literal>currentSession()</literal>,特定的实现用它来负责跟踪当前的上下文session。Hibernate内置了此接口的两种实现。
+ 请参阅<literal>org.hibernate.context.CurrentSessionContext</literal>接口的Javadoc,那里有关于它的契约的详细讨论。它定义了单一的方法,<literal>currentSession()</literal>,特定的实现用它来负责跟踪当前的上下文session。Hibernate内置了此接口的三种实现。
</para>
<itemizedlist>
@@ -261,14 +261,19 @@
<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - 当前session通过当前执行的线程来跟踪和界定。详情也请参阅Javadoc。
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>org.hibernate.context.ManagedSessionContext</literal> - 当前session通过当前执行的线程来跟踪和界定。但是,你需要负责使用这个类的静态方法将<literal>Session</literal>实例绑定、或者取消绑定,它并不会打开(open)、flush或者关闭(close)任何<literal>Session</literal>。
+ </para>
+ </listitem>
</itemizedlist>
<para>
- 这两种实现都提供了“每数据库事务对应一个session”的编程模型,也称作<emphasis>每次请求一个session</emphasis>。Hibernate session的起始和终结由数据库事务的生存来控制。假若你采用自行编写代码来管理事务(比如,在纯粹的J2SE,或者JTA/UserTransaction/BMT),建议你使用Hibernate <literal>Transaction</literal> API来把底层事务实现从你的代码中隐藏掉。如果你在支持CMT的EJB容器中执行,事务边界是声明式定义的,你不需要在代码中进行任何事务或session管理操作。请参阅<xref linkend="transactions"/>一节来阅读更多的内容和示例代码。
+ 前两种实现都提供了“每数据库事务对应一个session”的编程模型,也称作<emphasis>每次请求一个session</emphasis>。Hibernate session的起始和终结由数据库事务的生存来控制。假若你在纯粹的 Java SE之上采用自行编写代码来管理事务,而不使用JTA,建议你使用Hibernate <literal>Transaction</literal> API来把底层事务实现从你的代码中隐藏掉。如果你使用JTA,请使用JTA借口来管理Transaction。如果你在支持CMT的EJB容器中执行代码,事务边界是声明式定义的,你不需要在代码中进行任何事务或session管理操作。请参阅<xref linkend="transactions"/>一节来阅读更多的内容和示例代码。
</para>
<para>
- <literal>hibernate.current_session_context_class</literal>配置参数定义了应该采用哪个<literal>org.hibernate.context.CurrentSessionContext</literal>实现。注意,为了向下兼容,如果未配置此参数,但是存在<literal>org.hibernate.transaction.TransactionManagerLookup</literal>的配置,Hibernate会采用<literal>org.hibernate.context.JTASessionContext</literal>。一般而言,此参数的值指明了要使用的实现类的全名,但那两个内置的实现可以使用简写,即"jta"和"thread"。
+ <literal>hibernate.current_session_context_class</literal>配置参数定义了应该采用哪个<literal>org.hibernate.context.CurrentSessionContext</literal>实现。注意,为了向下兼容,如果未配置此参数,但是存在<literal>org.hibernate.transaction.TransactionManagerLookup</literal>的配置,Hibernate会采用<literal>org.hibernate.context.JTASessionContext</literal>。一般而言,此参数的值指明了要使用的实现类的全名,但那三种内置的实现可以使用简写,即"jta"、"thread"和"managed"。
</para>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/basic_mapping.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/basic_mapping.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/basic_mapping.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -93,7 +93,7 @@
- <sect2 id="mapping-declaration-doctype" revision="2">
+ <sect2 id="mapping-declaration-doctype" revision="3">
<title>Doctype</title>
<para>
@@ -102,6 +102,53 @@
或<literal>hibernate.jar</literal>文件中找到。Hibernate总是会首先在它的classptah中搜索DTD文件。
如果你发现它是通过连接Internet查找DTD文件,就对照你的classpath目录检查XML文件里的DTD声明。
</para>
+
+ <sect3 id="mapping-declaration-entity-resolution">
+ <title>EntityResolver</title>
+ <para>
+ As mentioned previously, Hibernate will first attempt to resolve DTDs in its classpath. The
+ manner in which it does this is by registering a custom <literal>org.xml.sax.EntityResolver</literal>
+ implementation with the SAXReader it uses to read in the xml files. This custom
+ <literal>EntityResolver</literal> recognizes two different systemId namespaces.
+ 如前所述,Hibernate首先在其classpath中查找DTD。其行为是依靠在系统中注册的<literal>org.xml.sax.EntityResolver</literal>的一个具体实现,SAXReader依靠它来读取xml文件。这一 <literal>EntityResolver</literal> 实现能辨认两种不同的 systenId命名空间。
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ 若resolver遇到了一个以<literal>http://hibernate.sourceforge.net/</literal>为开头的systemId,它会辨认出是<literal>hibernate namespace</literal>,resolver就试图通过加载Hibernate类的classloader来查找这些实体。
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+
+ 若resolver遇到了一个使用<literal>classpath://</literal>URL协议的systemId,它会辨认出这是<literal>user namespace</literal>,resolver试图通过(1)当前线程上下文的classloader和(2)加载Hibernate class的classloader来查找这些实体。
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ 使用user namespace(用户命名空间)的例子:
+ </para>
+ <programlisting><![CDATA[<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" [
+ <!ENTITY types SYSTEM "classpath://your/domain/types.xml">
+]>
+
+<hibernate-mapping package="your.domain">
+ <class name="MyEntity">
+ <id name="id" type="my-custom-id-type">
+ ...
+ </id>
+ <class>
+ &types;
+</hibernate-mapping>]]></programlisting>
+ <para>
+ <literal>types.xml</literal>是<literal>your.domain</literal>包中的一个资源,它包含了一个定制的<xref linkend="mapping-types-custom">typedef</xref>。
+ </para>
+
+ </sect3>
+
</sect2>
<sect2 id="mapping-declaration-mapping" revision="3">
@@ -693,6 +740,15 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>sequence-identity</literal></term>
+ <listitem>
+ <para>
+ 一种特别的序列生成策略,使用数据库序列来生成实际值,但将它和JDBC3的getGeneratedKeys结合在一起,使得在插入语句执行的时候就返回生成的值。目前为止只有面向JDK 1.4的Oracle 10g驱动支持这一策略。注意,因为Oracle驱动程序的一个bug,这些插入语句的注释被关闭了。(原文:Note comments on these insert statements are disabled due to a bug in the Oracle drivers.)
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</para>
@@ -2141,7 +2197,7 @@
<title>连接(join)</title>
<para>
- 使用 <literal><join></literal> 元素,可以将一个类的属性映射到多张表中。
+ 使用 <literal><join></literal> 元素,假若在表之间存在一对一关联,可以将一个类的属性映射到多张表中。
</para>
<programlistingco>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/batch.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/batch.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/batch.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -26,6 +26,10 @@
<programlisting><![CDATA[hibernate.jdbc.batch_size 20]]></programlisting>
+ <para id="disablebatching" revision="1">
+ 注意,假若你使用了<literal>identiy</literal>标识符生成器,Hibernate在JDBC级别透明的关闭插入语句的批量执行。
+ </para>
+
<para>
你也可能想在执行批量处理时关闭二级缓存:
</para>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/configuration.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/configuration.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/configuration.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -685,9 +685,15 @@
为JDBC事务策略选择<literal>after_transaction</literal>.
<para>
<emphasis role="strong">取值</emphasis>
- <literal>on_close</literal> | <literal>after_transaction</literal> |
- <literal>after_statement</literal> | <literal>auto</literal>
+ <literal>auto</literal> (默认) | <literal>on_close</literal> |
+ <literal>after_transaction</literal> | <literal>after_statement</literal>
</para>
+ <para>
+
+ 注意,这些设置仅对通过<literal>SessionFactory.openSession</literal>得到的<literal>Session</literal>起作用。对于通过<literal>SessionFactory.getCurrentSession</literal>得到的<literal>Session</literal>,所配置的<literal>CurrentSessionContext</literal>实现控制这些<literal>Session</literal>的连接释放模式。请参阅<xref linkend="architecture-current-session"/>。
+ </para>
+
+
</entry>
</row>
<row>
@@ -902,7 +908,7 @@
</tgroup>
</table>
- <table frame="topbot" id="configuration-misc-properties" revision="9">
+ <table frame="topbot" id="configuration-misc-properties" revision="10">
<title>
其他属性
</title>
@@ -931,7 +937,7 @@
<para>
<emphasis role="strong">eg.</emphasis>
<literal>jta</literal> | <literal>thread</literal> |
- <literal>custom.Class</literal>
+ <literal>managed</literal> | <literal>custom.Class</literal>
</para>
</entry>
</row>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/filters.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/filters.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/filters.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -7,7 +7,7 @@
对于某个特定的Hibernate session您可以选择是否启用(或禁用)某个过滤器。
</para>
- <sect1 id="objectstate-filters">
+ <sect1 id="objectstate-filters" revision="1">
<title>Hibernate 过滤器(filters)</title>
<para>
@@ -122,7 +122,19 @@
最安全的方式是使用左外连接(left outer joining)。并且通常来说,先写参数,
然后是操作符,最后写数据库字段名。
</para>
+
+ <para>
+ 在Filter定义之后,它可能被附加到多个实体和/或集合类,每个都有自己的条件。假若这些条件都是一样的,每次都要定义就显得很繁琐。因此,<literal><filter-def/></literal>被用来定义一个默认条件,它可能作为属性或者CDATA出现:
+ </para>
+ <programlisting><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
+<filter-def name="myOtherFilter">abc=xyz</filter-def>]]></programlisting>
+
+ <para>
+ 当这个filter被附加到任何目的地,而又没有指明条件时,这个条件就会被使用。注意,换句话说,你可以通过给filter附加特别的条件来重载默认条件。
+ </para>
+
+
</sect1>
</chapter>
\ No newline at end of file
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/performance.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/performance.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/performance.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -564,10 +564,8 @@
(即使可以将缓存数据设定为定期失效)。
</para>
- <para>
- 默认情况下,Hibernate使用EHCache进行JVM级别的缓存(目前,Hibernate已经废弃了对JCS的支持,未来版本中将会去掉它)。
- 你可以通过设置<literal>hibernate.cache.provider_class</literal>属性,指定其他的缓存策略,
- 该缓存策略必须实现<literal>org.hibernate.cache.CacheProvider</literal>接口。
+ <para revision="1">
+ 通过在<literal>hibernate.cache.provider_class</literal>属性中指定<literal>org.hibernate.cache.CacheProvider</literal>的某个实现的类名,你可以选择让Hibernate使用哪个缓存实现。Hibernate打包一些开源缓存实现,提供对它们的内置支持(见下表)。除此之外,你也可以实现你自己的实现,将它们插入到系统中。注意,在3.2版本之前,默认使用EhCache 作为缓存实现,但从3.2起就不再这样了。
</para>
<table frame="topbot" id="cacheproviders" revision="1">
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/persistent_classes.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/persistent_classes.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/persistent_classes.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -435,11 +435,11 @@
</para>
</sect1>
- <sect1 id="persistent-classes-tuplizers" revision="0">
+ <sect1 id="persistent-classes-tuplizers" revision="1">
<title>元组片断映射(Tuplizers)</title>
<para>
- <literal>org.hibernate.tuple.Tuplizer</literal>,以及其子接口,负责根据给定的<literal>org.hibernate.EntityMode</literal>,来复现片断数据。如果给定的片断数据被认为其是一种数据结构,"tuplizer"就是一个知道如何创建这样的数据结构,以及如何给这个数据结构赋值的东西。比如说,对于POJO这种Entity Mode,对应的tuplizer知道通过其构造方法来创建一个POJO,再通过其属性访问器来访问POJO属性。有两大类高层Tuplizer,分别是<literal>org.hibernate.tuple.EntityTuplizer</literal> 和<literal>org.hibernate.tuple.ComponentTuplizer</literal>接口。<literal>EntityTuplizer</literal>负责管理上面提到的实体的契约,而<literal>ComponentTuplizer</literal>则是针对组件的。
+ <literal>org.hibernate.tuple.Tuplizer</literal>,以及其子接口,负责根据给定的<literal>org.hibernate.EntityMode</literal>,来复现片断数据。如果给定的片断数据被认为其是一种数据结构,"tuplizer"就是一个知道如何创建这样的数据结构,以及如何给这个数据结构赋值的东西。比如说,对于POJO这种Entity Mode,对应的tuplizer知道通过其构造方法来创建一个POJO,再通过其属性访问器来访问POJO属性。有两大类高层Tuplizer,分别是<literal>org.hibernate.tuple.entity.EntityTuplizer</literal> 和<literal>org.hibernate.tuple.entity.ComponentTuplizer</literal>接口。<literal>EntityTuplizer</literal>负责管理上面提到的实体的契约,而<literal>ComponentTuplizer</literal>则是针对组件的。
</para>
<para>
@@ -466,7 +466,7 @@
public class CustomMapTuplizerImpl
- extends org.hibernate.tuple.DynamicMapEntityTuplizer {
+ extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {
// override the buildInstantiator() method to plug in our custom map...
protected final Instantiator buildInstantiator(
org.hibernate.mapping.PersistentClass mappingInfo) {
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/query_hql.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/query_hql.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/query_hql.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -772,7 +772,7 @@
</para>
</sect1>
- <sect1 id="queryhql-grouping">
+ <sect1 id="queryhql-grouping" revision="1">
<title>group by子句</title>
<para>
@@ -804,13 +804,15 @@
<programlisting><![CDATA[select cat
from Cat cat
join cat.kittens kitten
-group by cat
+group by cat.id, cat.name, cat.other, cat.properties
having avg(kitten.weight) > 100
order by count(kitten) asc, sum(kitten.weight) desc]]></programlisting>
<para>
注意<literal>group by</literal>子句与
<literal>order by</literal>子句中都不能包含算术表达式(arithmetic expressions).
+
+ 也要注意Hibernate目前不会扩展group的实体,因此你不能写<literal>group by cat</literal>,除非<literal>cat</literal>的所有属性都不是聚集的(non-aggregated)。你必须明确的列出所有的非聚集属性。
</para>
</sect1>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/query_sql.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/query_sql.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/query_sql.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -10,15 +10,36 @@
Hibernate3允许你使用手写的sql来完成所有的create,update,delete,和load操作(包括存储过程)
</para>
- <sect1 id="querysql-creating" revision="3">
+ <sect1 id="querysql-creating" revision="4">
<title>使用<literal>SQLQuery</literal></title>
- <para>对原生SQL查询执行的控制是通过<literal>SQLQuery</literal>接口进行的,通过执行<literal>Session.createSQLQuery()</literal>获取这个接口。最简单的情况下,我们可以采用以下形式:</para>
+ <para>对原生SQL查询执行的控制是通过<literal>SQLQuery</literal>接口进行的,通过执行<literal>Session.createSQLQuery()</literal>获取这个接口。下面来描述如何使用这个API进行查询。</para>
- <programlisting><![CDATA[List cats = sess.createSQLQuery("select * from cats")
- .addEntity(Cat.class)
- .list();]]></programlisting>
+ <sect2>
+ <title>标量查询(Scalar queries)</title>
+ <para>
+ 最基本的SQL查询就是获得一个标量(数值)的列表。 </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").list();
+sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").list();
+]]></programlisting>
+
+ <para>
+ 它们都将返回一个Object数组(Object[])组成的List,数组每个元素都是CATS表的一个字段值。Hibernate会使用ResultSetMetadata来判定返回的标量值的实际顺序和类型。
+ </para>
+
+ <para>
+ 如果要避免过多的使用<literal>ResultSetMetadata</literal>,或者只是为了更加明确的指名返回值,可以使用<literal>addScalar()</literal>。
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ .addScalar("ID", Hibernate.LONG)
+ .addScalar("NAME", Hibernate.STRING)
+ .addScalar("BIRTHDATE", Hibernate.DATE)
+]]></programlisting>
+
+
<para>这个查询指定了:</para>
<itemizedlist>
@@ -27,89 +48,164 @@
</listitem>
<listitem>
- <para>查询返回的实体</para>
+ <para>要返回的字段和类型</para>
</listitem>
</itemizedlist>
- <para>这里,结果集字段名被假设为与映射文件中指明的字段名相同。对于连接了多个表的查询,这就可能造成问题,因为可能在多个表中出现同样名字的字段。下面的方法就可以避免字段名重复的问题:</para>
+ <para>
+ 它仍然会返回Object数组,但是此时不再使用<literal>ResultSetMetdata</literal>,而是明确的将ID,NAME和BIRTHDATE按照Long,String和Short类型从resultset中取出。同时,也指明了就算query是使用<literal>*</literal>来查询的,可能获得超过列出的这三个字段,也仅仅会返回这三个字段。
+ </para>
- <programlisting><![CDATA[List cats = sess.createSQLQuery("select {cat.*} from cats cat")
- .addEntity("cat", Cat.class)
- .list();]]></programlisting>
+ <para>
+ 对全部或者部分的标量值不设置类型信息也是可以的。
+ </para>
- <para>
- 这个查询指定了:
- </para>
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS")
+ .addScalar("ID", Hibernate.LONG)
+ .addScalar("NAME")
+ .addScalar("BIRTHDATE")
+]]></programlisting>
- <itemizedlist>
+ <para>
+ 基本上这和前面一个查询相同,只是此时使用<literal>ResultSetMetaData</literal>来决定NAME和BIRTHDATE的类型,而ID的类型是明确指出的。
+ </para>
+
+ <para>
+ 关于从ResultSetMetaData返回的java.sql.Types是如何映射到Hibernate类型,是由方言(Dialect)控制的。假若某个指定的类型没有被映射,或者不是你所预期的类型,你可以通过Dialet的<literal>registerHibernateType</literal>调用自行定义。
+ </para>
+
+ </sect2>
+
+ <sect2>
+ <title>实体查询(Entity queries)</title>
+
+ <para>
+ 上面的查询都是返回标量值的,也就是从resultset中返回的“裸”数据。下面展示如何通过<literal>addEntity()</literal>让原生查询返回实体对象。
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT * FROM CATS").addEntity(Cat.class);
+sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").addEntity(Cat.class);
+]]></programlisting>
+
+ <para>这个查询指定:</para>
+
+ <itemizedlist>
<listitem>
- <para>
- SQL查询语句,它带一个占位符,可以让Hibernate使用字段的别名.
- </para>
+ <para>SQL查询字符串</para>
</listitem>
+
<listitem>
- <para>
- 查询返回的实体,和它的SQL表的别名.
- </para>
+ <para>要返回的实体</para>
</listitem>
- </itemizedlist>
-
- <para>
- <literal>addEntity()</literal>方法将SQL表的别名和实体类联系起来,并且确定查询结果集的形态。
- </para>
-
- <para>
- <literal>addJoin()</literal>方法可以被用于载入其他的实体和集合的关联.
- </para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery(
- "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
- )
- .addEntity("cat", Cat.class)
- .addJoin("kitten", "cat.kittens")
- .list();]]></programlisting>
-
- <para>
- 原生的SQL查询可能返回一个简单的标量值或者一个标量和实体的结合体。
- </para>
+ </itemizedlist>
- <programlisting><![CDATA[Double max = (Double) sess.createSQLQuery("select max(cat.weight) as maxWeight from cats cat")
- .addScalar("maxWeight", Hibernate.DOUBLE);
- .uniqueResult();]]></programlisting>
-
- <para>除此之外,你还可以在你的hbm文件中描述结果集映射信息,在查询中使用。</para>
-
- <programlisting><![CDATA[List cats = sess.createSQLQuery(
- "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
- )
- .setResultSetMapping("catAndKitten")
- .list();]]></programlisting>
+ <para>
+ 假设Cat被映射为拥有ID,NAME和BIRTHDATE三个字段的类,以上的两个查询都返回一个List,每个元素都是一个Cat实体。
+ </para>
+ <para>
+ 假若实体在映射时有一个<literal>many-to-one</literal>的关联指向另外一个实体,在查询时必须也返回那个实体,否则会导致发生一个"column not found"的数据库错误。这些附加的字段可以使用*标注来自动返回,但我们希望还是明确指明,看下面这个具有指向<literal>Dog</literal>的<literal>many-to-one</literal>的例子:
+ </para>
- </sect1>
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS").addEntity(Cat.class);
+]]></programlisting>
- <sect1 id="querysql-aliasreferences">
- <title>别名和属性引用</title>
+ <para>
+ 这样cat.getDog()就能正常运作。
+ </para>
+ </sect2>
- <para>
- 上面使用的<literal>{cat.*}</literal>标记是 "所有属性" 的简写.你可以显式地列出需要的字段,但是你必须让Hibernate
- 为每一个属性注入字段的别名.这些字段的站位符是以字段别名为前导,再加上属性名.在下面的例子里,我们从一个其他的表(<literal>cat_log</literal>)
- 中获取<literal>Cat</literal>对象,而非Cat对象原本在映射元数据中声明的表.注意我们甚至在where子句中也可以使用属性别名.
- 对于命名查询,{}语法并不是必需的.你可以在<xref linkend="querysql-namedqueries"/>得到更多的细节.
- </para>
+ <sect2>
+ <title>处理关联和集合类(Handling associations and collections)</title>
- <programlisting><![CDATA[String sql = "select cat.originalId as {cat.id}, " +
- "cat.mateid as {cat.mate}, cat.sex as {cat.sex}, " +
- "cat.weight*10 as {cat.weight}, cat.name as {cat.name} " +
- "from cat_log cat where {cat.mate} = :catId"
-
+ <para>
+ 通过提前抓取将<literal>Dog</literal>连接获得,而避免初始化proxy带来的额外开销也是可能的。这是通过<literal>addJoin()</literal>方法进行的,这个方法可以让你将关联或集合连接进来。
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, DOG_ID, D_ID, D_NAME FROM CATS c, DOGS d WHERE c.DOG_ID = d.D_ID")
+ .addEntity("cat", Cat.class)
+ .addJoin("cat.dog");
+]]></programlisting>
+
+ <para>
+ 上面这个例子中,返回的<literal>Cat</literal>对象,其<literal>dog</literal>属性被完全初始化了,不再需要数据库的额外操作。注意,我们加了一个别名("cat"),以便指明join的目标属性路径。通过同样的提前连接也可以作用于集合类,例如,假若<literal>Cat</literal>有一个指向<literal>Dog</literal>的一对多关联。
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, CAT_ID FROM CATS c, DOGS d WHERE c.ID = d.CAT_ID")
+ .addEntity("cat", Cat.class)
+ .addJoin("cat.dogs");
+]]></programlisting>
+
+ <p>
+ 到此为止,我们碰到了天花板:若不对SQL查询进行增强,这些已经是在Hibernate中使用原生SQL查询所能做到的最大可能了。下面的问题即将出现:返回多个同样类型的实体怎么办?或者默认的别名/字段不够又怎么办?
+
+ </p>
+ </sect2>
+
+ <sect2>
+ <title>返回多个实体(Returning multiple entities)</title>
+
+ <para>
+ 到目前为止,结果集字段名被假定为和映射文件中指定的的字段名是一致的。假若SQL查询连接了多个表,同一个字段名可能在多个表中出现多次,这就会造成问题。
+ </para>
+
+ <para>
+ 下面的查询中需要使用字段别名注射(这个例子本身会失败):
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT c.*, m.* FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
+ .addEntity("cat", Cat.class)
+ .addEntity("mother", Cat.class)
+]]></programlisting>
+
+ <para>
+ 这个查询的本意是希望每行返回两个Cat实例,一个是cat,另一个是它的妈妈。但是因为它们的字段名被映射为相同的,而且在某些数据库中,返回的字段别名是“c.ID”,"c.NAME"这样的形式,而它们和在映射文件中的名字("ID"和"NAME")不匹配,这就会造成失败。
+
+ </para>
+
+ <para>
+ 下面的形式可以解决字段名重复:
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID")
+ .addEntity("cat", Cat.class)
+ .addEntity("mother", Cat.class)
+]]></programlisting>
+
+ <para>这个查询指明:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ SQL查询语句,其中包含占位附来让Hibernate注射字段别名</para>
+ </listitem>
+
+ <listitem>
+ <para>
+ 查询返回的实体
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ 上面使用的{cat.*}和{mother.*}标记是作为“所有属性”的简写形式出现的。当然你也可以明确地罗列出字段名,但在这个例子里面我们让Hibernate来为每个属性注射SQL字段别名。字段别名的占位符是属性名加上表别名的前缀。在下面的例子中,我们从另外一个表(cat_log)中通过映射元数据中的指定获取Cat和它的妈妈。注意,要是我们愿意,我们甚至可以在where子句中使用属性别名。
+
+ </para>
+
+ <programlisting><![CDATA[String sql = "SELECT ID as {c.id}, NAME as {c.name}, " +
+ "BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " +
+ "FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID";
+
List loggedCats = sess.createSQLQuery(sql)
- .addEntity("cat", Cat.class)
- .setLong("catId", catId)
- .list();]]></programlisting>
+ .addEntity("cat", Cat.class)
+ .addEntity("mother", Cat.class).list()
+]]></programlisting>
+ <sect3 id="querysql-aliasreferences" revision="2">
+ <title>别名和属性引用(Alias and property references)</title>
+
<para>
- <emphasis>注意:</emphasis>如果你明确地列出了每个属性,你必须包含<emphasis>这个类</emphasis>和<emphasis>它的子类</emphasis>的属性!
+ 大多数情况下,都需要上面的属性注射,但在使用更加复杂的映射,比如复合属性、通过标识符构造继承树,以及集合类等等情况下,也有一些特别的别名,来允许Hibernate注射合适的别名。
</para>
<para>
@@ -119,7 +215,7 @@
<table frame="topbot" id="aliasinjection-summary">
<title>别名注射(alias injection names)</title>
- <tgroup cols="4">
+ <tgroup cols="3">
<colspec colwidth="1*" />
<colspec colwidth="1*" />
@@ -129,7 +225,9 @@
<thead>
<row>
<entry>描述</entry>
+
<entry>语法</entry>
+
<entry>示例</entry>
</row>
</thead>
@@ -190,8 +288,64 @@
</table>
- </sect1>
+ </sect3>
+ </sect2>
+
+ <sect2>
+ <title>返回非受管实体(Returning non-managed entities)</title>
+
+ <para>
+ 可以对原生sql 查询使用ResultTransformer。这会返回不受Hibernate管理的实体。
+
+ </para>
+
+ <programlisting><![CDATA[sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM CATS")
+ .setResultTransformer(Transformers.aliasToBean(CatDTO.class))]]></programlisting>
+
+ <para>这个查询指定:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>SQL查询字符串</para>
+ </listitem>
+
+ <listitem>
+ <para>结果转换器(result transformer)</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ 上面的查询将会返回<literal>CatDTO</literal>的列表,它将被实例化并且将NAME和BIRTHDAY的值注射入对应的属性或者字段。
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>处理继承(Handling inheritance)</title>
+
+ <para>
+ 原生SQL查询假若其查询结果实体是继承树中的一部分,它必须包含基类和所有子类的所有属性。
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>参数(Parameters)</title>
+
+ <para>
+ 原生查询支持位置参数和命名参数:
+ </para>
+
+ <programlisting><![CDATA[Query query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like ?").addEntity(Cat.class);
+List pusList = query.setString(0, "Pus%").list();
+
+query = sess.createSQLQuery("SELECT * FROM CATS WHERE NAME like :name").addEntity(Cat.class);
+List pusList = query.setString("name", "Pus%").list(); ]]></programlisting>
+ </sect2>
+
+
+ </sect1>
+
+
<sect1 id="querysql-namedqueries" revision="3">
<title>命名SQL查询</title>
@@ -272,6 +426,16 @@
ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'
WHERE person.NAME LIKE :namePattern
</sql-query>]]></programlisting>
+
+ <para>
+ 另外,你可以在java代码中直接使用hbm文件中的结果集定义信息。
+ </para>
+
+ <programlisting><![CDATA[List cats = sess.createSQLQuery(
+ "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id"
+ )
+ .setResultSetMapping("catAndKitten")
+ .list();]]></programlisting>
<sect2 id="propertyresults">
<title>使用return-property来明确地指定字段/别名</title>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/session_api.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/session_api.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/session_api.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -408,7 +408,7 @@
</sect3>
- <sect3 id="objectstate-querying-executing-named">
+ <sect3 id="objectstate-querying-executing-named" revision="1">
<title>外置命名查询(Externalizing named queries)</title>
<para>
@@ -416,7 +416,7 @@
(如果你的查询串中包含可能被解释为XML标记(markup)的字符,别忘了用<literal>CDATA</literal>包裹起来。)
</para>
- <programlisting><![CDATA[<query name="eg.DomesticCat.by.name.and.minimum.weight"><![CDATA[
+ <programlisting><![CDATA[<query name="ByNameAndMaximumWeight"><![CDATA[
from eg.DomesticCat as cat
where cat.name = ?
and cat.weight > ?
@@ -427,7 +427,7 @@
参数绑定及执行以编程方式(programatically)完成:
</para>
- <programlisting><![CDATA[Query q = sess.getNamedQuery("eg.DomesticCat.by.name.and.minimum.weight");
+ <programlisting><![CDATA[Query q = sess.getNamedQuery("ByNameAndMaximumWeight");
q.setString(0, name);
q.setInt(1, minWeight);
List cats = q.list();]]></programlisting>
@@ -438,6 +438,11 @@
或将原有的其他的查询语句放在配置文件中,这样就可以让Hibernate统一管理,达到迁移的目的。
</para>
+ <para>
+
+ 也请注意在<literal><hibernate-mapping></literal>元素中声明的查询必须有一个全局唯一的名字,而在<literal><class></literal>元素中声明的查询自动具有全局名,是通过类的全名加以限定的。比如<literal>eg.Cat.ByNameAndMaximumWeight</literal>。
+ </para>
+
</sect3>
</sect2>
Modified: trunk/Hibernate3/doc/reference/zh-cn/modules/tutorial.xml
===================================================================
--- trunk/Hibernate3/doc/reference/zh-cn/modules/tutorial.xml 2006-11-07 01:16:53 UTC (rev 10743)
+++ trunk/Hibernate3/doc/reference/zh-cn/modules/tutorial.xml 2006-11-07 05:58:20 UTC (rev 10744)
@@ -258,7 +258,7 @@
</para>
<para>
- 在开发的根目录下创建一个<literal>data</literal>目录 - 这是HSQL DB存储数据文件的地方。此时在data目录中运行<literal>java -classpath lib/hsqldb.jar org.hsqldb.Server</literal>就可启动数据库。你可以在log中看到它的启动,及绑定到TCP/IP套结字,这正是我们的应用程序稍后会连接的地方。如果你希望在本例中运行一个全新的数据库,就在窗口中按下<literal>CTRL + C</literal>来关闭HSQL数据库,并删除<literal>data/</literal>目录下的所有文件,再重新启动HSQL数据库。
+ 在开发的根目录下创建一个<literal>data</literal>目录 - 这是HSQL DB存储数据文件的地方。此时在data目录中运行<literal>java -classpath ../lib/hsqldb.jar org.hsqldb.Server</literal>就可启动数据库。你可以在log中看到它的启动,及绑定到TCP/IP套结字,这正是我们的应用程序稍后会连接的地方。如果你希望在本例中运行一个全新的数据库,就在窗口中按下<literal>CTRL + C</literal>来关闭HSQL数据库,并删除<literal>data/</literal>目录下的所有文件,再重新启动HSQL数据库。
</para>
<para>
@@ -462,7 +462,7 @@
</sect2>
- <sect2 id="tutorial-firstapp-workingpersistence" revision="4">
+ <sect2 id="tutorial-firstapp-workingpersistence" revision="5">
<title>
加载并存储对象
</title>
@@ -518,10 +518,22 @@
</para>
<para>
- <literal>sessionFactory.getCurrentSession()</literal>是干什么的呢?首先,只要你持有<literal>SessionFactory</literal>(幸亏我们有<literal>HibernateUtil</literal>,可以随时获得),大可在任何时候、任何地点调用这个方法。<literal>getCurrentSession()</literal>方法总会返回“当前的”工作单元。记得我们在<literal>hibernate.cfg.xml</literal>中把这一配置选项调整为"thread"了吗?因此,当前工作单元的范围就是当前执行我们应用程序的Java线程。但是,这并非总是正确的。 <literal>Session</literal>在第一次被使用的时候,或者第一次调用<literal>getCurrentSession()</literal>的时候,其生命周期就开始。然后它被Hibernate绑定到当前线程。当事务结束的时候,不管是提交还是回滚,Hibernate也会把<literal>Session</literal>从当前线程剥离,并且关闭它。假若你再次调用<literal>getCurrentSession()</lit!
eral>,你会得到一个新的<literal>Session</literal>,并且开始一个新的工作单元。这种<emphasis>线程绑定(thread-bound)</emphasis>的编程模型(model)是使用Hibernate的最广泛的方式。
+ <literal>sessionFactory.getCurrentSession()</literal>是干什么的呢?首先,只要你持有<literal>SessionFactory</literal>(幸亏我们有<literal>HibernateUtil</literal>,可以随时获得),大可在任何时候、任何地点调用这个方法。<literal>getCurrentSession()</literal>方法总会返回“当前的”工作单元。记得我们在<literal>hibernate.cfg.xml</literal>中把这一配置选项调整为"thread"了吗?因此,因此,当前工作单元被绑定到当前执行我们应用程序的Java线程。但是,这并非是完全准确的,你还得考虑工作单元的生命周期范围 (scope),它何时开始,又何时结束.
+ </para>
+
+ <para>
+ <literal>Session</literal>在第一次被使用的时候,即第一次调用<literal>getCurrentSession()</literal>的时候,其生命周期就开始。然后它被Hibernate绑定到当前线程。当事务结束的时候,不管是提交还是回滚,Hibernate会自动把<literal>Session</literal>从当前线程剥离,并且关闭它。假若你再次调用<literal>getCurrentSession()</literal>,你会得到一个新的<literal>Session</literal>,并且开始一个新的工作单元。这种<emphasis>线程绑定(thread-bound)</emphasis>的编程模型(model)是使用Hibernate的最广泛的方式,因为它支持对你的代码灵活分层(事务划分可以和你的数据访问代码分离开来,在本教程的后面部分就会这么做)。
+
</para>
<para>
+
+ 和工作单元的生命周期这个话题相关,Hibernate <literal>Session</literal>是否被应该用来执行多次数据库操作?上面的例子对每一次操作使用了一个<literal>Session</literal>,这完全是巧合,这个例子不是很复杂,无法展示其他方式。Hibernate <literal>Session</literal>的生命周期可以很灵活,但是你绝不要把你的应用程序设计成为<emphasis>每一次</emphasis>数据库操作都用一个新的Hibernate <literal>Session</literal>。因此就算下面的例子(它们都很简单)中你可以看到这种用法,记住<emphasis>每次操作一个session</emphasis>是一个反模式。在本教程的后面会展示一个真正的(web)程序。
+ </para>
+
+
+
+ <para>
关于事务处理及事务边界界定的详细信息,请参看<xref linkend="transactions"/>。在上面的例子中,我们也忽略了所有的错误与回滚的处理。
</para>
@@ -750,7 +762,7 @@
</sect2>
- <sect2 id="tutorial-associations-working" revision="1">
+ <sect2 id="tutorial-associations-working" revision="2">
<title>
使关联工作
</title>
@@ -820,7 +832,8 @@
Long eventId = mgr.createAndStoreEvent("My Event", new Date());
Long personId = mgr.createAndStorePerson("Foo", "Bar");
mgr.addPersonToEvent(personId, eventId);
- System.out.println("Added person " + personId + " to event " + eventId);]]></programlisting>
+ System.out.println("Added person " + personId + " to event " + eventId);
+}]]></programlisting>
<para>
上面是个关于两个同等重要的实体类间关联的例子。像前面所提到的那样,在特定的模型中也存在其它的类和类型,这些类和类型通常是“次要的”。你已看到过其中的一些,像<literal>int</literal>或<literal>String</literal>。我们称这些类为<emphasis>值类型(value type)</emphasis>,它们的实例<emphasis>依赖(depend)</emphasis>在某个特定的实体上。这些类型的实例没有它们自己的标识(identity),也不能在实体间被共享(比如,两个person不能引用同一个<literal>firstname</literal>对象,即使他们有相同的first name)。当然,值类型并不仅仅在JDK中存在(事实上,在一个Hibernate应用程序中,所有的JDK类都被视为值类型),而且你也可以编写你自己的依赖类,例如<literal>Address</literal>,<literal>MonetaryAmount</literal>。
@@ -1001,7 +1014,7 @@
Hibernate web应用程序使用<literal>Session</literal> 和<literal>Transaction</literal>的方式几乎和独立应用程序是一样的。但是,有一些常见的模式(pattern)非常有用。现在我们编写一个<literal>EventManagerServlet</literal>。这个servlet可以列出数据库中保存的所有的events,还提供一个HTML表单来增加新的events。
</para>
- <sect2 id="tutorial-webapp-servlet">
+ <sect2 id="tutorial-webapp-servlet" revision="2">
<title>编写基本的servlet</title>
<para>
@@ -1014,9 +1027,6 @@
public class EventManagerServlet extends HttpServlet {
- private final SimpleDateFormat dateFormatter =
- new SimpleDateFormat("dd.MM.yyyy");
-
// Servlet code
}]]></programlisting>
@@ -1032,6 +1042,8 @@
HttpServletResponse response)
throws ServletException, IOException {
+ SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy");
+
try {
// Begin unit of work
HibernateUtil.getSessionFactory()
@@ -1050,11 +1062,15 @@
}
}]]></programlisting>
-
<para>
我们称这里应用的模式为每次请求一个session<emphasis>(session-per-request)</emphasis>。当有请求到达这个servlet的时候,通过对<literal>SessionFactory</literal>的第一次调用,打开一个新的Hibernate <literal>Session</literal>。然后启动一个数据库事务—所有的数据访问都是在事务中进行,不管是读还是写(我们在应用程序中不使用auto-commit模式)。
</para>
+
+ <para>
+ <emphasis>不要</emphasis>为每次数据库操作都使用一个新的Hibernate <literal>Session</literal>。将Hibernate <literal>Session</literal>的范围设置为整个请求。要用<literal>getCurrentSession()</literal>,这样它自动会绑定到当前Java线程。
+ </para>
+
<para>
下一步,对请求的可能动作进行处理,渲染出反馈的HTML。我们很快就会涉及到那部分。
</para>
@@ -1065,7 +1081,7 @@
</sect2>
- <sect2 id="tutorial-webapp-processing">
+ <sect2 id="tutorial-webapp-processing" revision="1">
<title>处理与渲染</title>
<para>
@@ -1092,31 +1108,18 @@
// Print page
printEventForm(out);
-listEvents(out);
+listEvents(out, dateFormatter);
// Write HTML footer
out.println("</body></html>");
out.flush();
out.close();]]></programlisting>
-
<para>
- 必须承认,这种编码风格让Java与HTML混合在了一起,在更复杂的应用程序中不应大量地使用—记住我们在章中仅为了展示Hibernate的基本概念。这段代码打印出了HTML头和尾部。在页面中,打印出一个输入event条目的表单,并列出数据库中所有events。第一个方法微不足道,仅仅是输出HTML:
+ <literal>listEvents()</literal>方法使用绑定到当前线程的Hibernate <literal>Session</literal>来执行查询:
</para>
- <programlisting><![CDATA[private void printEventForm(PrintWriter out) {
- out.println("<h2>Add new event:</h2>");
- out.println("<form>");
- out.println("Title: <input name='eventTitle' length='50'/><br/>");
- out.println("Date (e.g. 24.12.2009): <input name='eventDate' length='10'/><br/>");
- out.println("<input type='submit' name='action' value='store'/>");
- out.println("</form>");
-}]]></programlisting>
+ <programlisting><![CDATA[private void listEvents(PrintWriter out, SimpleDateFormat dateFormatter) {
- <para>
- <literal>listEvents()</literal>方法使用绑定到当前线程的Hibernate <literal>Session</literal>来执行查询:
- </para>
-
- <programlisting><![CDATA[private void listEvents(PrintWriter out) {
List result = HibernateUtil.getSessionFactory()
.getCurrentSession().createCriteria(Event.class).list();
if (result.size() > 0) {
18 years, 2 months
Hibernate SVN: r10743 - in branches/Lucene_Integration/HibernateExt/metadata/src: java/org/hibernate/search java/org/hibernate/search/engine java/org/hibernate/search/event java/org/hibernate/search/query java/org/hibernate/search/util test/org/hibernate/search/test test/org/hibernate/search/test/bridge test/org/hibernate/search/test/fieldAccess test/org/hibernate/search/test/inheritance test/org/hibernate/search/test/query test/org/hibernate/search/test/session
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-06 20:16:53 -0500 (Mon, 06 Nov 2006)
New Revision: 10743
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/FullTextSession.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/FullTextEventListener.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java
Log:
ANN-488 renaming
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/FullTextSession.java (from rev 10742, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/FullTextSession.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -0,0 +1,465 @@
+//$Id: $
+package org.hibernate.search;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+import javax.transaction.Status;
+
+import org.hibernate.CacheMode;
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.Filter;
+import org.hibernate.FlushMode;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.ReplicationMode;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.engine.query.ParameterMetadata;
+import org.hibernate.impl.SessionImpl;
+import org.hibernate.search.query.FullTextQueryImpl;
+import org.hibernate.search.event.FullTextEventListener;
+import org.hibernate.search.util.ContextHelper;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.stat.SessionStatistics;
+import org.hibernate.type.Type;
+import org.apache.lucene.document.Document;
+
+/**
+ * Lucene aware session that allows lucene query creations
+ *
+ * @author Emmanuel Bernard
+ */
+public class FullTextSession implements Session {
+ private final SessionImpl session;
+ private PostTransactionWorkQueueSynchronization postTransactionWorkQueueSynch;
+
+ public FullTextSession(Session session) {
+ this.session = (SessionImpl) session;
+ }
+
+ /**
+ * Execute a Lucene query and retrieve managed objects of type entities (or their indexed subclasses)
+ * If entities is empty, include all indexed entities
+ *
+ * @param entities must be immutable for the lifetime of the query object
+ */
+ public Query createLuceneQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
+ return new FullTextQueryImpl( luceneQuery, entities, session, new ParameterMetadata(null, null) );
+ }
+
+ /**
+ * (re)index an entity.
+ * Non indexable entities are ignored
+ * The entity must be associated with the session
+ *
+ * @param entity must not be null
+ */
+ public void index(Object entity) {
+ if (entity == null) return;
+ Class clazz = entity.getClass();
+ FullTextEventListener listener = ContextHelper.getLuceneEventListener( session );
+ DocumentBuilder<Object> builder = listener.getDocumentBuilders().get( clazz );
+ if ( builder != null ) {
+ Serializable id = session.getIdentifier( entity );
+ Document doc = builder.getDocument( entity, id );
+ UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
+ processWork( work, listener.getDocumentBuilders(), listener.getLockableDirectoryProviders() );
+ }
+ //TODO
+ //need to add elements in a queue kept at the Session level
+ //the queue will be processed by a Lucene(Auto)FlushEventListener
+ //note that we could keep this queue somewhere in the event listener in the mean time but that requires
+ // a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
+ //an other solution would be to subclass SessionImpl instead of having this LuceneSession delecation model
+ // this is an open discussion
+ }
+
+ private void processWork(Work work, Map<Class, DocumentBuilder<Object>> documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ if ( session.isTransactionInProgress() ) {
+ if ( postTransactionWorkQueueSynch == null || postTransactionWorkQueueSynch.isConsumed() ) {
+ postTransactionWorkQueueSynch = createWorkQueueSync( documentBuilders, lockableDirectoryProviders);
+ session.getTransaction().registerSynchronization( postTransactionWorkQueueSynch );
+ }
+ postTransactionWorkQueueSynch.add( work );
+ }
+ else {
+ //no transaction work right away
+ PostTransactionWorkQueueSynchronization sync =
+ createWorkQueueSync( documentBuilders, lockableDirectoryProviders );
+ sync.add( work );
+ sync.afterCompletion( Status.STATUS_COMMITTED );
+ }
+ }
+
+ private PostTransactionWorkQueueSynchronization createWorkQueueSync(
+ Map<Class, DocumentBuilder<Object>> documentBuilders,
+ Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
+ WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders, lockableDirectoryProviders );
+ return new PostTransactionWorkQueueSynchronization( workQueue );
+ }
+
+ public Query createSQLQuery(String sql, String returnAlias, Class returnClass) {
+ return session.createSQLQuery( sql, returnAlias, returnClass );
+ }
+
+ public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses) {
+ return session.createSQLQuery( sql, returnAliases, returnClasses );
+ }
+
+ public int delete(String query) throws HibernateException {
+ return session.delete( query );
+ }
+
+ public int delete(String query, Object value, Type type) throws HibernateException {
+ return session.delete( query, value, type );
+ }
+
+ public int delete(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.delete( query, values, types );
+ }
+
+ public Collection filter(Object collection, String filter) throws HibernateException {
+ return session.filter( collection, filter );
+ }
+
+ public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException {
+ return session.filter( collection, filter, value, type );
+ }
+
+ public Collection filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException {
+ return session.filter( collection, filter, values, types );
+ }
+
+ public List find(String query) throws HibernateException {
+ return session.find( query );
+ }
+
+ public List find(String query, Object value, Type type) throws HibernateException {
+ return session.find( query, value, type );
+ }
+
+ public List find(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.find( query, values, types );
+ }
+
+ public Iterator iterate(String query) throws HibernateException {
+ return session.iterate( query );
+ }
+
+ public Iterator iterate(String query, Object value, Type type) throws HibernateException {
+ return session.iterate( query, value, type );
+ }
+
+ public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException {
+ return session.iterate( query, values, types );
+ }
+
+ public void save(String entityName, Object object, Serializable id) throws HibernateException {
+ session.save( entityName, object, id );
+ }
+
+ public void save(Object object, Serializable id) throws HibernateException {
+ session.save( object, id );
+ }
+
+ public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException {
+ return session.saveOrUpdateCopy( entityName, object );
+ }
+
+ public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException {
+ return session.saveOrUpdateCopy( entityName, object, id );
+ }
+
+ public Object saveOrUpdateCopy(Object object) throws HibernateException {
+ return session.saveOrUpdateCopy( object );
+ }
+
+ public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException {
+ return session.saveOrUpdateCopy( object, id );
+ }
+
+ public void update(String entityName, Object object, Serializable id) throws HibernateException {
+ session.update( entityName, object, id );
+ }
+
+ public void update(Object object, Serializable id) throws HibernateException {
+ session.update( object, id );
+ }
+
+ public Transaction beginTransaction() throws HibernateException {
+ return session.beginTransaction();
+ }
+
+ public void cancelQuery() throws HibernateException {
+ session.cancelQuery();
+ }
+
+ public void clear() {
+ session.clear();
+ }
+
+ public Connection close() throws HibernateException {
+ return session.close();
+ }
+
+ public Connection connection() throws HibernateException {
+ return session.connection();
+ }
+
+ public boolean contains(Object object) {
+ return session.contains( object );
+ }
+
+ public Criteria createCriteria(String entityName) {
+ return session.createCriteria( entityName );
+ }
+
+ public Criteria createCriteria(String entityName, String alias) {
+ return session.createCriteria( entityName, alias );
+ }
+
+ public Criteria createCriteria(Class persistentClass) {
+ return session.createCriteria( persistentClass );
+ }
+
+ public Criteria createCriteria(Class persistentClass, String alias) {
+ return session.createCriteria( persistentClass, alias );
+ }
+
+ public Query createFilter(Object collection, String queryString) throws HibernateException {
+ return session.createFilter( collection, queryString );
+ }
+
+ public Query createQuery(String queryString) throws HibernateException {
+ return session.createQuery( queryString );
+ }
+
+ public SQLQuery createSQLQuery(String queryString) throws HibernateException {
+ return session.createSQLQuery( queryString );
+ }
+
+ public void delete(String entityName, Object object) throws HibernateException {
+ session.delete( entityName, object );
+ }
+
+ public void delete(Object object) throws HibernateException {
+ session.delete( object );
+ }
+
+ public void disableFilter(String filterName) {
+ session.disableFilter( filterName );
+ }
+
+ public Connection disconnect() throws HibernateException {
+ return session.disconnect();
+ }
+
+ public Filter enableFilter(String filterName) {
+ return session.enableFilter( filterName );
+ }
+
+ public void evict(Object object) throws HibernateException {
+ session.evict( object );
+ }
+
+ public void flush() throws HibernateException {
+ session.flush();
+ }
+
+ public Object get(Class clazz, Serializable id) throws HibernateException {
+ return session.get( clazz, id );
+ }
+
+ public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.get( clazz, id, lockMode );
+ }
+
+ public Object get(String entityName, Serializable id) throws HibernateException {
+ return session.get( entityName, id );
+ }
+
+ public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.get( entityName, id, lockMode );
+ }
+
+ public CacheMode getCacheMode() {
+ return session.getCacheMode();
+ }
+
+ public LockMode getCurrentLockMode(Object object) throws HibernateException {
+ return session.getCurrentLockMode( object );
+ }
+
+ public Filter getEnabledFilter(String filterName) {
+ return session.getEnabledFilter( filterName );
+ }
+
+ public EntityMode getEntityMode() {
+ return session.getEntityMode();
+ }
+
+ public String getEntityName(Object object) throws HibernateException {
+ return session.getEntityName( object );
+ }
+
+ public FlushMode getFlushMode() {
+ return session.getFlushMode();
+ }
+
+ public Serializable getIdentifier(Object object) throws HibernateException {
+ return session.getIdentifier( object );
+ }
+
+ public Query getNamedQuery(String queryName) throws HibernateException {
+ return session.getNamedQuery( queryName );
+ }
+
+ public org.hibernate.Session getSession(EntityMode entityMode) {
+ return session.getSession( entityMode );
+ }
+
+ public SessionFactory getSessionFactory() {
+ return session.getSessionFactory();
+ }
+
+ public SessionStatistics getStatistics() {
+ return session.getStatistics();
+ }
+
+ public Transaction getTransaction() {
+ return session.getTransaction();
+ }
+
+ public boolean isConnected() {
+ return session.isConnected();
+ }
+
+ public boolean isDirty() throws HibernateException {
+ return session.isDirty();
+ }
+
+ public boolean isOpen() {
+ return session.isOpen();
+ }
+
+ public Object load(String entityName, Serializable id) throws HibernateException {
+ return session.load( entityName, id );
+ }
+
+ public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.load( entityName, id, lockMode );
+ }
+
+ public void load(Object object, Serializable id) throws HibernateException {
+ session.load( object, id );
+ }
+
+ public Object load(Class theClass, Serializable id) throws HibernateException {
+ return session.load( theClass, id );
+ }
+
+ public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException {
+ return session.load( theClass, id, lockMode );
+ }
+
+ public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException {
+ session.lock( entityName, object, lockMode );
+ }
+
+ public void lock(Object object, LockMode lockMode) throws HibernateException {
+ session.lock( object, lockMode );
+ }
+
+ public Object merge(String entityName, Object object) throws HibernateException {
+ return session.merge( entityName, object );
+ }
+
+ public Object merge(Object object) throws HibernateException {
+ return session.merge( object );
+ }
+
+ public void persist(String entityName, Object object) throws HibernateException {
+ session.persist( entityName, object );
+ }
+
+ public void persist(Object object) throws HibernateException {
+ session.persist( object );
+ }
+
+ public void reconnect() throws HibernateException {
+ session.reconnect();
+ }
+
+ public void reconnect(Connection connection) throws HibernateException {
+ session.reconnect( connection );
+ }
+
+ public void refresh(Object object) throws HibernateException {
+ session.refresh( object );
+ }
+
+ public void refresh(Object object, LockMode lockMode) throws HibernateException {
+ session.refresh( object, lockMode );
+ }
+
+ public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException {
+ session.replicate( entityName, object, replicationMode );
+ }
+
+ public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException {
+ session.replicate( object, replicationMode );
+ }
+
+ public Serializable save(String entityName, Object object) throws HibernateException {
+ return session.save( entityName, object );
+ }
+
+ public Serializable save(Object object) throws HibernateException {
+ return session.save( object );
+ }
+
+ public void saveOrUpdate(String entityName, Object object) throws HibernateException {
+ session.saveOrUpdate( entityName, object );
+ }
+
+ public void saveOrUpdate(Object object) throws HibernateException {
+ session.saveOrUpdate( object );
+ }
+
+ public void setCacheMode(CacheMode cacheMode) {
+ session.setCacheMode( cacheMode );
+ }
+
+ public void setFlushMode(FlushMode flushMode) {
+ session.setFlushMode( flushMode );
+ }
+
+ public void setReadOnly(Object entity, boolean readOnly) {
+ session.setReadOnly( entity, readOnly );
+ }
+
+ public void update(String entityName, Object object) throws HibernateException {
+ session.update( entityName, object );
+ }
+
+ public void update(Object object) throws HibernateException {
+ session.update( object );
+ }
+}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -1,466 +0,0 @@
-//$Id: $
-package org.hibernate.search;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.transaction.Status;
-
-import org.hibernate.CacheMode;
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.Filter;
-import org.hibernate.FlushMode;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.Query;
-import org.hibernate.ReplicationMode;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.impl.SessionImpl;
-import org.hibernate.search.query.LuceneQueryImpl;
-import org.hibernate.search.event.LuceneEventListener;
-import org.hibernate.search.util.ContextHelper;
-import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.backend.UpdateWork;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkQueue;
-import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
-import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.stat.SessionStatistics;
-import org.hibernate.type.Type;
-import org.apache.lucene.document.Document;
-
-/**
- * Lucene aware session that allows lucene query creations
- *
- * @author Emmanuel Bernard
- */
-public class LuceneSession implements Session {
- private final SessionImpl session;
- private PostTransactionWorkQueueSynchronization postTransactionWorkQueueSynch;
-
- public LuceneSession(Session session) {
- this.session = (SessionImpl) session;
- }
-
- /**
- * Execute a Lucene query and retrieve managed objects of type entities (or their indexed subclasses)
- * If entities is empty, include all indexed entities
- *
- * @param entities must be immutable for the lifetime of the query object
- */
- public Query createLuceneQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
- return new LuceneQueryImpl( luceneQuery, entities, session, new ParameterMetadata(null, null) );
- }
-
- /**
- * (re)index an entity.
- * Non indexable entities are ignored
- * The entity must be associated with the session
- *
- * @param entity must not be null
- */
- public void index(Object entity) {
- if (entity == null) return;
- Class clazz = entity.getClass();
- LuceneEventListener listener = ContextHelper.getLuceneEventListener( session );
- DocumentBuilder<Object> builder = listener.getDocumentBuilders().get( clazz );
- if ( builder != null ) {
- Serializable id = session.getIdentifier( entity );
- Document doc = builder.getDocument( entity, id );
- UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
- processWork( work, listener.getDocumentBuilders(), listener.getLockableDirectoryProviders() );
- }
- //TODO
- //need to add elements in a queue kept at the Session level
- //the queue will be processed by a Lucene(Auto)FlushEventListener
- //note that we could keep this queue somewhere in the event listener in the mean time but that requires
- // a synchronized hashmap holding this queue on a per session basis plus some session house keeping (yuk)
- //an other solution would be to subclass SessionImpl instead of having this LuceneSession delecation model
- // this is an open discussion
- }
-
- private void processWork(Work work, Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- if ( session.isTransactionInProgress() ) {
- if ( postTransactionWorkQueueSynch == null || postTransactionWorkQueueSynch.isConsumed() ) {
- postTransactionWorkQueueSynch = createWorkQueueSync( documentBuilders, lockableDirectoryProviders);
- session.getTransaction().registerSynchronization( postTransactionWorkQueueSynch );
- }
- postTransactionWorkQueueSynch.add( work );
- }
- else {
- //no transaction work right away
- PostTransactionWorkQueueSynchronization sync =
- createWorkQueueSync( documentBuilders, lockableDirectoryProviders );
- sync.add( work );
- sync.afterCompletion( Status.STATUS_COMMITTED );
- }
- }
-
- private PostTransactionWorkQueueSynchronization createWorkQueueSync(
- Map<Class, DocumentBuilder<Object>> documentBuilders,
- Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders) {
- WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders, lockableDirectoryProviders );
- return new PostTransactionWorkQueueSynchronization( workQueue );
- }
-
- public Query createSQLQuery(String sql, String returnAlias, Class returnClass) {
- return session.createSQLQuery( sql, returnAlias, returnClass );
- }
-
- public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses) {
- return session.createSQLQuery( sql, returnAliases, returnClasses );
- }
-
- public int delete(String query) throws HibernateException {
- return session.delete( query );
- }
-
- public int delete(String query, Object value, Type type) throws HibernateException {
- return session.delete( query, value, type );
- }
-
- public int delete(String query, Object[] values, Type[] types) throws HibernateException {
- return session.delete( query, values, types );
- }
-
- public Collection filter(Object collection, String filter) throws HibernateException {
- return session.filter( collection, filter );
- }
-
- public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException {
- return session.filter( collection, filter, value, type );
- }
-
- public Collection filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException {
- return session.filter( collection, filter, values, types );
- }
-
- public List find(String query) throws HibernateException {
- return session.find( query );
- }
-
- public List find(String query, Object value, Type type) throws HibernateException {
- return session.find( query, value, type );
- }
-
- public List find(String query, Object[] values, Type[] types) throws HibernateException {
- return session.find( query, values, types );
- }
-
- public Iterator iterate(String query) throws HibernateException {
- return session.iterate( query );
- }
-
- public Iterator iterate(String query, Object value, Type type) throws HibernateException {
- return session.iterate( query, value, type );
- }
-
- public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException {
- return session.iterate( query, values, types );
- }
-
- public void save(String entityName, Object object, Serializable id) throws HibernateException {
- session.save( entityName, object, id );
- }
-
- public void save(Object object, Serializable id) throws HibernateException {
- session.save( object, id );
- }
-
- public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException {
- return session.saveOrUpdateCopy( entityName, object );
- }
-
- public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException {
- return session.saveOrUpdateCopy( entityName, object, id );
- }
-
- public Object saveOrUpdateCopy(Object object) throws HibernateException {
- return session.saveOrUpdateCopy( object );
- }
-
- public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException {
- return session.saveOrUpdateCopy( object, id );
- }
-
- public void update(String entityName, Object object, Serializable id) throws HibernateException {
- session.update( entityName, object, id );
- }
-
- public void update(Object object, Serializable id) throws HibernateException {
- session.update( object, id );
- }
-
- public Transaction beginTransaction() throws HibernateException {
- return session.beginTransaction();
- }
-
- public void cancelQuery() throws HibernateException {
- session.cancelQuery();
- }
-
- public void clear() {
- session.clear();
- }
-
- public Connection close() throws HibernateException {
- return session.close();
- }
-
- public Connection connection() throws HibernateException {
- return session.connection();
- }
-
- public boolean contains(Object object) {
- return session.contains( object );
- }
-
- public Criteria createCriteria(String entityName) {
- return session.createCriteria( entityName );
- }
-
- public Criteria createCriteria(String entityName, String alias) {
- return session.createCriteria( entityName, alias );
- }
-
- public Criteria createCriteria(Class persistentClass) {
- return session.createCriteria( persistentClass );
- }
-
- public Criteria createCriteria(Class persistentClass, String alias) {
- return session.createCriteria( persistentClass, alias );
- }
-
- public Query createFilter(Object collection, String queryString) throws HibernateException {
- return session.createFilter( collection, queryString );
- }
-
- public Query createQuery(String queryString) throws HibernateException {
- return session.createQuery( queryString );
- }
-
- public SQLQuery createSQLQuery(String queryString) throws HibernateException {
- return session.createSQLQuery( queryString );
- }
-
- public void delete(String entityName, Object object) throws HibernateException {
- session.delete( entityName, object );
- }
-
- public void delete(Object object) throws HibernateException {
- session.delete( object );
- }
-
- public void disableFilter(String filterName) {
- session.disableFilter( filterName );
- }
-
- public Connection disconnect() throws HibernateException {
- return session.disconnect();
- }
-
- public Filter enableFilter(String filterName) {
- return session.enableFilter( filterName );
- }
-
- public void evict(Object object) throws HibernateException {
- session.evict( object );
- }
-
- public void flush() throws HibernateException {
- session.flush();
- }
-
- public Object get(Class clazz, Serializable id) throws HibernateException {
- return session.get( clazz, id );
- }
-
- public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException {
- return session.get( clazz, id, lockMode );
- }
-
- public Object get(String entityName, Serializable id) throws HibernateException {
- return session.get( entityName, id );
- }
-
- public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
- return session.get( entityName, id, lockMode );
- }
-
- public CacheMode getCacheMode() {
- return session.getCacheMode();
- }
-
- public LockMode getCurrentLockMode(Object object) throws HibernateException {
- return session.getCurrentLockMode( object );
- }
-
- public Filter getEnabledFilter(String filterName) {
- return session.getEnabledFilter( filterName );
- }
-
- public EntityMode getEntityMode() {
- return session.getEntityMode();
- }
-
- public String getEntityName(Object object) throws HibernateException {
- return session.getEntityName( object );
- }
-
- public FlushMode getFlushMode() {
- return session.getFlushMode();
- }
-
- public Serializable getIdentifier(Object object) throws HibernateException {
- return session.getIdentifier( object );
- }
-
- public Query getNamedQuery(String queryName) throws HibernateException {
- return session.getNamedQuery( queryName );
- }
-
- public org.hibernate.Session getSession(EntityMode entityMode) {
- return session.getSession( entityMode );
- }
-
- public SessionFactory getSessionFactory() {
- return session.getSessionFactory();
- }
-
- public SessionStatistics getStatistics() {
- return session.getStatistics();
- }
-
- public Transaction getTransaction() {
- return session.getTransaction();
- }
-
- public boolean isConnected() {
- return session.isConnected();
- }
-
- public boolean isDirty() throws HibernateException {
- return session.isDirty();
- }
-
- public boolean isOpen() {
- return session.isOpen();
- }
-
- public Object load(String entityName, Serializable id) throws HibernateException {
- return session.load( entityName, id );
- }
-
- public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
- return session.load( entityName, id, lockMode );
- }
-
- public void load(Object object, Serializable id) throws HibernateException {
- session.load( object, id );
- }
-
- public Object load(Class theClass, Serializable id) throws HibernateException {
- return session.load( theClass, id );
- }
-
- public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException {
- return session.load( theClass, id, lockMode );
- }
-
- public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException {
- session.lock( entityName, object, lockMode );
- }
-
- public void lock(Object object, LockMode lockMode) throws HibernateException {
- session.lock( object, lockMode );
- }
-
- public Object merge(String entityName, Object object) throws HibernateException {
- return session.merge( entityName, object );
- }
-
- public Object merge(Object object) throws HibernateException {
- return session.merge( object );
- }
-
- public void persist(String entityName, Object object) throws HibernateException {
- session.persist( entityName, object );
- }
-
- public void persist(Object object) throws HibernateException {
- session.persist( object );
- }
-
- public void reconnect() throws HibernateException {
- session.reconnect();
- }
-
- public void reconnect(Connection connection) throws HibernateException {
- session.reconnect( connection );
- }
-
- public void refresh(Object object) throws HibernateException {
- session.refresh( object );
- }
-
- public void refresh(Object object, LockMode lockMode) throws HibernateException {
- session.refresh( object, lockMode );
- }
-
- public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException {
- session.replicate( entityName, object, replicationMode );
- }
-
- public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException {
- session.replicate( object, replicationMode );
- }
-
- public Serializable save(String entityName, Object object) throws HibernateException {
- return session.save( entityName, object );
- }
-
- public Serializable save(Object object) throws HibernateException {
- return session.save( object );
- }
-
- public void saveOrUpdate(String entityName, Object object) throws HibernateException {
- session.saveOrUpdate( entityName, object );
- }
-
- public void saveOrUpdate(Object object) throws HibernateException {
- session.saveOrUpdate( object );
- }
-
- public void setCacheMode(CacheMode cacheMode) {
- session.setCacheMode( cacheMode );
- }
-
- public void setFlushMode(FlushMode flushMode) {
- session.setFlushMode( flushMode );
- }
-
- public void setReadOnly(Object entity, boolean readOnly) {
- session.setReadOnly( entity, readOnly );
- }
-
- public void update(String entityName, Object object) throws HibernateException {
- session.update( entityName, object );
- }
-
- public void update(Object object) throws HibernateException {
- session.update( object );
- }
-}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -26,7 +26,7 @@
import org.hibernate.search.bridge.BridgeFactory;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.IdFieldBridge;
-import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.event.FullTextEventListener;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.util.BinderHelper;
import org.hibernate.reflection.ReflectionManager;
@@ -305,7 +305,7 @@
}
}
- public static Serializable getDocumentId(LuceneEventListener listener, Class clazz, Document document) {
+ public static Serializable getDocumentId(FullTextEventListener listener, Class clazz, Document document) {
DocumentBuilder builder = listener.getDocumentBuilders().get( clazz );
if ( builder == null ) throw new HibernateException( "No Lucene configuration set up for: " + clazz.getName() );
return (Serializable) builder.getIdBridge().get( builder.getIdKeywordName(), document );
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/FullTextEventListener.java (from rev 10742, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/FullTextEventListener.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -0,0 +1,180 @@
+//$Id$
+package org.hibernate.search.event;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantLock;
+import javax.transaction.Status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.event.AbstractEvent;
+import org.hibernate.event.Initializable;
+import org.hibernate.event.PostDeleteEvent;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PostInsertEvent;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PostUpdateEvent;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.search.Environment;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.backend.AddWork;
+import org.hibernate.search.backend.DeleteWork;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.DirectoryProviderFactory;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.reflection.ReflectionManager;
+import org.hibernate.reflection.XClass;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * This listener supports setting a parent directory for all generated index files.
+ * It also supports setting the analyzer class to be used.
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Mattias Arbin
+ */
+//TODO work on sharing the same indexWriters and readers across a single post operation...
+//TODO implement and use a LockableDirectoryProvider that wraps a DP to handle the lock inside the LDP
+public class FullTextEventListener implements PostDeleteEventListener, PostInsertEventListener,
+ PostUpdateEventListener, Initializable {
+ ReflectionManager reflectionManager;
+
+ //FIXME keeping this here is a bad decision since you might want to search indexes wo maintain it
+ @Deprecated
+ public Map<Class, DocumentBuilder<Object>> getDocumentBuilders() {
+ return documentBuilders;
+ }
+
+
+ private Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
+ //keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
+ private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
+ new HashMap<DirectoryProvider, ReentrantLock>();
+ private boolean initialized;
+
+ private static final Log log = LogFactory.getLog( FullTextEventListener.class );
+
+ public void initialize(Configuration cfg) {
+ if ( initialized ) return;
+ //yuk
+ reflectionManager = ( (AnnotationConfiguration) cfg ).createExtendedMappings().getReflectionManager();
+
+ Class analyzerClass;
+ String analyzerClassName = cfg.getProperty( Environment.ANALYZER_CLASS );
+ if ( analyzerClassName != null ) {
+ try {
+ analyzerClass = ReflectHelper.classForName( analyzerClassName );
+ }
+ catch (Exception e) {
+ throw new HibernateException(
+ "Lucene analyzer class '" + analyzerClassName + "' defined in property '" + Environment.ANALYZER_CLASS + "' could not be found.",
+ e
+ );
+ }
+ }
+ else {
+ analyzerClass = StandardAnalyzer.class;
+ }
+ // Initialize analyzer
+ Analyzer analyzer;
+ try {
+ analyzer = (Analyzer) analyzerClass.newInstance();
+ }
+ catch (ClassCastException e) {
+ throw new HibernateException(
+ "Lucene analyzer does not implement " + Analyzer.class.getName() + ": " + analyzerClassName
+ );
+ }
+ catch (Exception e) {
+ throw new HibernateException( "Failed to instantiate lucene analyzer with type " + analyzerClassName );
+ }
+
+ Iterator iter = cfg.getClassMappings();
+ DirectoryProviderFactory factory = new DirectoryProviderFactory();
+ while ( iter.hasNext() ) {
+ PersistentClass clazz = (PersistentClass) iter.next();
+ Class<?> mappedClass = clazz.getMappedClass();
+ if ( mappedClass != null ) {
+ XClass mappedXClass = reflectionManager.toXClass( mappedClass );
+ if ( mappedXClass != null && mappedXClass.isAnnotationPresent( Indexed.class ) ) {
+ DirectoryProvider provider = factory.createDirectoryProvider( mappedXClass, cfg );
+ if ( !lockableDirectoryProviders.containsKey( provider ) ) {
+ lockableDirectoryProviders.put( provider, new ReentrantLock() );
+ }
+ final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>(
+ mappedXClass, analyzer, provider, reflectionManager
+ );
+
+ documentBuilders.put( mappedClass, documentBuilder );
+ }
+ }
+ }
+ Set<Class> indexedClasses = documentBuilders.keySet();
+ for ( DocumentBuilder builder : documentBuilders.values() ) {
+ builder.postInitialize( indexedClasses );
+ }
+ initialized = true;
+ }
+
+ public void onPostDelete(PostDeleteEvent event) {
+ if ( documentBuilders.containsKey( event.getEntity().getClass() ) ) {
+ DeleteWork work = new DeleteWork( event.getId(), event.getEntity().getClass() );
+ processWork( work, event );
+ }
+ }
+
+ public void onPostInsert(PostInsertEvent event) {
+ final Object entity = event.getEntity();
+ DocumentBuilder<Object> builder = documentBuilders.get( entity.getClass() );
+ if ( builder != null ) {
+ Serializable id = event.getId();
+ Document doc = builder.getDocument( entity, id );
+ AddWork work = new AddWork( id, entity.getClass(), doc );
+ processWork( work, event );
+ }
+ }
+
+ public void onPostUpdate(PostUpdateEvent event) {
+ final Object entity = event.getEntity();
+ DocumentBuilder<Object> builder = documentBuilders.get( entity.getClass() );
+ if ( builder != null ) {
+ Serializable id = event.getId();
+ Document doc = builder.getDocument( entity, id );
+ UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
+ processWork( work, event );
+ }
+ }
+
+ private void processWork(Work work, AbstractEvent event) {
+ WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders, lockableDirectoryProviders );
+ workQueue.add( work );
+ PostTransactionWorkQueueSynchronization sync = new PostTransactionWorkQueueSynchronization( workQueue );
+ if ( event.getSession().isTransactionInProgress() ) {
+ event.getSession().getTransaction().registerSynchronization( sync );
+ }
+ else {
+ sync.afterCompletion( Status.STATUS_COMMITTED );
+ }
+ }
+
+ public Map<DirectoryProvider, ReentrantLock> getLockableDirectoryProviders() {
+ return lockableDirectoryProviders;
+ }
+}
Property changes on: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/FullTextEventListener.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -1,180 +0,0 @@
-//$Id$
-package org.hibernate.search.event;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
-import javax.transaction.Status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.event.AbstractEvent;
-import org.hibernate.event.Initializable;
-import org.hibernate.event.PostDeleteEvent;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEvent;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEvent;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.search.Environment;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.backend.AddWork;
-import org.hibernate.search.backend.DeleteWork;
-import org.hibernate.search.backend.UpdateWork;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkQueue;
-import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
-import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
-import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.search.store.DirectoryProviderFactory;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.reflection.ReflectionManager;
-import org.hibernate.reflection.XClass;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * This listener supports setting a parent directory for all generated index files.
- * It also supports setting the analyzer class to be used.
- *
- * @author Gavin King
- * @author Emmanuel Bernard
- * @author Mattias Arbin
- */
-//TODO work on sharing the same indexWriters and readers across a single post operation...
-//TODO implement and use a LockableDirectoryProvider that wraps a DP to handle the lock inside the LDP
-public class LuceneEventListener implements PostDeleteEventListener, PostInsertEventListener,
- PostUpdateEventListener, Initializable {
- ReflectionManager reflectionManager;
-
- //FIXME keeping this here is a bad decision since you might want to search indexes wo maintain it
- @Deprecated
- public Map<Class, DocumentBuilder<Object>> getDocumentBuilders() {
- return documentBuilders;
- }
-
-
- private Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
- //keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
- private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
- new HashMap<DirectoryProvider, ReentrantLock>();
- private boolean initialized;
-
- private static final Log log = LogFactory.getLog( LuceneEventListener.class );
-
- public void initialize(Configuration cfg) {
- if ( initialized ) return;
- //yuk
- reflectionManager = ( (AnnotationConfiguration) cfg ).createExtendedMappings().getReflectionManager();
-
- Class analyzerClass;
- String analyzerClassName = cfg.getProperty( Environment.ANALYZER_CLASS );
- if ( analyzerClassName != null ) {
- try {
- analyzerClass = ReflectHelper.classForName( analyzerClassName );
- }
- catch (Exception e) {
- throw new HibernateException(
- "Lucene analyzer class '" + analyzerClassName + "' defined in property '" + Environment.ANALYZER_CLASS + "' could not be found.",
- e
- );
- }
- }
- else {
- analyzerClass = StandardAnalyzer.class;
- }
- // Initialize analyzer
- Analyzer analyzer;
- try {
- analyzer = (Analyzer) analyzerClass.newInstance();
- }
- catch (ClassCastException e) {
- throw new HibernateException(
- "Lucene analyzer does not implement " + Analyzer.class.getName() + ": " + analyzerClassName
- );
- }
- catch (Exception e) {
- throw new HibernateException( "Failed to instantiate lucene analyzer with type " + analyzerClassName );
- }
-
- Iterator iter = cfg.getClassMappings();
- DirectoryProviderFactory factory = new DirectoryProviderFactory();
- while ( iter.hasNext() ) {
- PersistentClass clazz = (PersistentClass) iter.next();
- Class<?> mappedClass = clazz.getMappedClass();
- if ( mappedClass != null ) {
- XClass mappedXClass = reflectionManager.toXClass( mappedClass );
- if ( mappedXClass != null && mappedXClass.isAnnotationPresent( Indexed.class ) ) {
- DirectoryProvider provider = factory.createDirectoryProvider( mappedXClass, cfg );
- if ( !lockableDirectoryProviders.containsKey( provider ) ) {
- lockableDirectoryProviders.put( provider, new ReentrantLock() );
- }
- final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>(
- mappedXClass, analyzer, provider, reflectionManager
- );
-
- documentBuilders.put( mappedClass, documentBuilder );
- }
- }
- }
- Set<Class> indexedClasses = documentBuilders.keySet();
- for ( DocumentBuilder builder : documentBuilders.values() ) {
- builder.postInitialize( indexedClasses );
- }
- initialized = true;
- }
-
- public void onPostDelete(PostDeleteEvent event) {
- if ( documentBuilders.containsKey( event.getEntity().getClass() ) ) {
- DeleteWork work = new DeleteWork( event.getId(), event.getEntity().getClass() );
- processWork( work, event );
- }
- }
-
- public void onPostInsert(PostInsertEvent event) {
- final Object entity = event.getEntity();
- DocumentBuilder<Object> builder = documentBuilders.get( entity.getClass() );
- if ( builder != null ) {
- Serializable id = event.getId();
- Document doc = builder.getDocument( entity, id );
- AddWork work = new AddWork( id, entity.getClass(), doc );
- processWork( work, event );
- }
- }
-
- public void onPostUpdate(PostUpdateEvent event) {
- final Object entity = event.getEntity();
- DocumentBuilder<Object> builder = documentBuilders.get( entity.getClass() );
- if ( builder != null ) {
- Serializable id = event.getId();
- Document doc = builder.getDocument( entity, id );
- UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
- processWork( work, event );
- }
- }
-
- private void processWork(Work work, AbstractEvent event) {
- WorkQueue workQueue = new BatchLuceneWorkQueue( documentBuilders, lockableDirectoryProviders );
- workQueue.add( work );
- PostTransactionWorkQueueSynchronization sync = new PostTransactionWorkQueueSynchronization( workQueue );
- if ( event.getSession().isTransactionInProgress() ) {
- event.getSession().getTransaction().registerSynchronization( sync );
- }
- else {
- sync.afterCompletion( Status.STATUS_COMMITTED );
- }
- }
-
- public Map<DirectoryProvider, ReentrantLock> getLockableDirectoryProviders() {
- return lockableDirectoryProviders;
- }
-}
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/FullTextQueryImpl.java (from rev 10742, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java)
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -0,0 +1,296 @@
+//$Id: $
+package org.hibernate.search.query;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MultiSearcher;
+import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.Directory;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.query.ParameterMetadata;
+import org.hibernate.impl.AbstractQueryImpl;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.event.FullTextEventListener;
+import org.hibernate.search.util.ContextHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+//TODO implements setParameter()
+public class FullTextQueryImpl extends AbstractQueryImpl {
+ private static final Log log = LogFactory.getLog( FullTextQueryImpl.class );
+ private org.apache.lucene.search.Query luceneQuery;
+ private Class[] classes;
+ private Set<Class> classesAndSubclasses;
+ private Integer firstResult;
+ private Integer maxResults;
+ private int resultSize;
+
+ /**
+ * classes must be immutable
+ */
+ public FullTextQueryImpl(org.apache.lucene.search.Query query, Class[] classes, SessionImplementor session,
+ ParameterMetadata parameterMetadata) {
+ //TODO handle flushMode
+ super( query.toString(), null, session, parameterMetadata );
+ this.luceneQuery = query;
+ this.classes = classes;
+ }
+
+ /**
+ * Return an interator on the results.
+ * Retrieve the object one by one (initialize it during the next() operation)
+ */
+ public Iterator iterate() throws HibernateException {
+ //implement an interator which keep the id/class for each hit and get the object on demand
+ //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
+ //user stop using it
+ //scrollable is better in this area
+
+ FullTextEventListener listener = ContextHelper.getLuceneEventListener( session );
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ try {
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ Hits hits = searcher.search( query );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ List<EntityInfo> entityInfos = new ArrayList<EntityInfo>( max - first + 1 );
+ for ( int index = first; index <= max; index++ ) {
+ Document document = hits.doc( index );
+ EntityInfo entityInfo = new EntityInfo();
+ entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
+ entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document );
+ entityInfos.add( entityInfo );
+ }
+ return new IteratorImpl( entityInfos, (Session) this.session );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ if ( searcher != null ) try {
+ searcher.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
+
+ public ScrollableResults scroll() throws HibernateException {
+ //keep the searcher open until the resultset is closed
+ FullTextEventListener listener = ContextHelper.getLuceneEventListener( session );;
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ Hits hits;
+ try {
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ hits = searcher.search( query );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ return new ScrollableResultsImpl( searcher, hits, first, max, (Session) this.session, listener );
+ }
+ catch (IOException e) {
+ try {
+ if ( searcher != null ) searcher.close();
+ }
+ catch (IOException ee) {
+ //we have the initial issue already
+ }
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ }
+
+ public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
+ //TODO think about this scrollmode
+ return scroll();
+ }
+
+ public List list() throws HibernateException {
+ FullTextEventListener listener = ContextHelper.getLuceneEventListener( session );;
+ //find the directories
+ Searcher searcher = buildSearcher( listener );
+ Hits hits;
+ try {
+ org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
+ hits = searcher.search( query );
+ setResultSize( hits );
+ int first = first();
+ int max = max( first, hits );
+ List result = new ArrayList( max - first + 1 );
+ Session sess = (Session) this.session;
+ for ( int index = first; index <= max; index++ ) {
+ Document document = hits.doc( index );
+ Class clazz = DocumentBuilder.getDocumentClass( document );
+ Serializable id = DocumentBuilder.getDocumentId( listener, clazz, document );
+ result.add( sess.load( clazz, id ) );
+ //use load to benefit from the batch-size
+ //we don't face proxy casting issues since the exact class is extracted from the index
+ }
+ //then initialize the objects
+ for ( Object element : result ) {
+ Hibernate.initialize( element );
+ }
+ return result;
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to query Lucene index", e );
+ }
+ finally {
+ if ( searcher != null ) try {
+ searcher.close();
+ }
+ catch (IOException e) {
+ log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
+ }
+ }
+ }
+
+ private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
+ //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
+ //it also probably minimise the memory footprint
+ if ( classesAndSubclasses == null ) {
+ return luceneQuery;
+ }
+ else {
+ BooleanQuery classFilter = new BooleanQuery();
+ //annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
+ classFilter.setBoost( 0 );
+ for ( Class clazz : classesAndSubclasses ) {
+ Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
+ TermQuery termQuery = new TermQuery( t );
+ classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
+ }
+ BooleanQuery filteredQuery = new BooleanQuery();
+ filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
+ filteredQuery.add( classFilter, BooleanClause.Occur.MUST );
+ return filteredQuery;
+ }
+ }
+
+ private int max(int first, Hits hits) {
+ return maxResults == null ?
+ hits.length() - 1 :
+ maxResults + first < hits.length() ?
+ first + maxResults - 1 :
+ hits.length() - 1;
+ }
+
+ private int first() {
+ return firstResult != null ?
+ firstResult :
+ 0;
+ }
+
+ //TODO change classesAndSubclasses by side effect, which is a mismatch with the Searcher return, fix that.
+ private Searcher buildSearcher(FullTextEventListener listener) {
+ Map<Class, DocumentBuilder<Object>> builders = listener.getDocumentBuilders();
+ Set<Directory> directories = new HashSet<Directory>();
+ if ( classes == null || classes.length == 0 ) {
+ //no class means all classes
+ for ( DocumentBuilder builder : builders.values() ) {
+ directories.add( builder.getDirectoryProvider().getDirectory() );
+ }
+ classesAndSubclasses = null;
+ }
+ else {
+ Set<Class> involvedClasses = new HashSet<Class>( classes.length );
+ Collections.addAll( involvedClasses, classes );
+ for ( Class clazz : classes ) {
+ DocumentBuilder builder = builders.get( clazz );
+ if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
+ }
+ for ( Class clazz : involvedClasses ) {
+ DocumentBuilder builder = builders.get( clazz );
+ //TODO should we rather choose a polymorphic path and allow non mapped entities
+ if ( builder == null ) throw new HibernateException( "Not a mapped entity: " + clazz );
+ directories.add( builder.getDirectoryProvider().getDirectory() );
+ }
+ classesAndSubclasses = involvedClasses;
+ }
+
+ //set up the searcher
+ Searcher searcher;
+ int dirNbr = directories.size();
+ if ( dirNbr > 1 ) {
+ try {
+ IndexSearcher[] searchers = new IndexSearcher[dirNbr];
+ Iterator<Directory> it = directories.iterator();
+ for ( int index = 0; index < dirNbr; index++ ) {
+ searchers[index] = new IndexSearcher( it.next() );
+ }
+ searcher = new MultiSearcher( searchers );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to read Lucene directory", e );
+ }
+ }
+ else {
+ try {
+ searcher = new IndexSearcher( directories.iterator().next() );
+ }
+ catch (IOException e) {
+ throw new HibernateException( "Unable to read Lucene directory", e );
+ }
+ }
+ return searcher;
+ }
+
+ private void setResultSize(Hits hits) {
+ resultSize = hits.length();
+ }
+
+ //FIXME does it make sense
+ public int resultSize() {
+ return this.resultSize;
+ }
+
+ public Query setFirstResult(int firstResult) {
+ this.firstResult = firstResult;
+ return this;
+ }
+
+ public Query setMaxResults(int maxResults) {
+ this.maxResults = maxResults;
+ return this;
+ }
+
+ public int executeUpdate() throws HibernateException {
+ throw new HibernateException( "Not supported operation" );
+ }
+
+ public Query setLockMode(String alias, LockMode lockMode) {
+ return null;
+ }
+
+ protected Map getLockModes() {
+ return null;
+ }
+}
Deleted: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -1,297 +0,0 @@
-//$Id: $
-package org.hibernate.search.query;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MultiSearcher;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.Directory;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.Query;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.impl.AbstractQueryImpl;
-import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.event.LuceneEventListener;
-import org.hibernate.search.util.ContextHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-//implements setParameter()
-public class LuceneQueryImpl extends AbstractQueryImpl {
- private static final Log log = LogFactory.getLog( LuceneQueryImpl.class );
- private org.apache.lucene.search.Query luceneQuery;
- private Class[] classes;
- private Set<Class> classesAndSubclasses;
- private Integer firstResult;
- private Integer maxResults;
- private int resultSize;
-
- /**
- * classes must be immutable
- */
- public LuceneQueryImpl(org.apache.lucene.search.Query query, Class[] classes, SessionImplementor session,
- ParameterMetadata parameterMetadata) {
- //TODO handle flushMode
- super( query.toString(), null, session, parameterMetadata );
- this.luceneQuery = query;
- this.classes = classes;
- }
-
- /**
- * Return an interator on the results.
- * Retrieve the object one by one (initialize it during the next() operation)
- */
- public Iterator iterate() throws HibernateException {
- //implement an interator which keep the id/class for each hit and get the object on demand
- //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
- //user stop using it
- //scrollable is better in this area
-
- LuceneEventListener listener = ContextHelper.getLuceneEventListener( session );
- //find the directories
- Searcher searcher = buildSearcher( listener );
- try {
- org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
- Hits hits = searcher.search( query );
- setResultSize( hits );
- int first = first();
- int max = max( first, hits );
- List<EntityInfo> entityInfos = new ArrayList<EntityInfo>( max - first + 1 );
- for ( int index = first; index <= max; index++ ) {
- Document document = hits.doc( index );
- EntityInfo entityInfo = new EntityInfo();
- entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
- entityInfo.id = DocumentBuilder.getDocumentId( listener, entityInfo.clazz, document );
- entityInfos.add( entityInfo );
- }
- return new IteratorImpl( entityInfos, (Session) this.session );
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- finally {
- if ( searcher != null ) try {
- searcher.close();
- }
- catch (IOException e) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- }
-
- public ScrollableResults scroll() throws HibernateException {
- //keep the searcher open until the resultset is closed
- LuceneEventListener listener = ContextHelper.getLuceneEventListener( session );;
- //find the directories
- Searcher searcher = buildSearcher( listener );
- Hits hits;
- try {
- org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
- hits = searcher.search( query );
- setResultSize( hits );
- int first = first();
- int max = max( first, hits );
- return new ScrollableResultsImpl( searcher, hits, first, max, (Session) this.session, listener );
- }
- catch (IOException e) {
- try {
- if ( searcher != null ) searcher.close();
- }
- catch (IOException ee) {
- //we have the initial issue already
- }
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- }
-
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
- //TODO think about this scrollmode
- return scroll();
- }
-
- public List list() throws HibernateException {
- LuceneEventListener listener = ContextHelper.getLuceneEventListener( session );;
- //find the directories
- Searcher searcher = buildSearcher( listener );
- Hits hits;
- try {
- org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
- hits = searcher.search( query );
- setResultSize( hits );
- int first = first();
- int max = max( first, hits );
- List result = new ArrayList( max - first + 1 );
- Session sess = (Session) this.session;
- for ( int index = first; index <= max; index++ ) {
- Document document = hits.doc( index );
- Class clazz = DocumentBuilder.getDocumentClass( document );
- Serializable id = DocumentBuilder.getDocumentId( listener, clazz, document );
- result.add( sess.load( clazz, id ) );
- //use load to benefit from the batch-size
- //we don't face proxy casting issues since the exact class is extracted from the index
- }
- //then initialize the objects
- for ( Object element : result ) {
- Hibernate.initialize( element );
- }
- return result;
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to query Lucene index", e );
- }
- finally {
- if ( searcher != null ) try {
- searcher.close();
- }
- catch (IOException e) {
- log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
- }
- }
- }
-
- private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
- //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
- //it also probably minimise the memory footprint
- if ( classesAndSubclasses == null ) {
- return luceneQuery;
- }
- else {
- BooleanQuery classFilter = new BooleanQuery();
- //annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
- classFilter.setBoost( 0 );
- for ( Class clazz : classesAndSubclasses ) {
- Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
- TermQuery termQuery = new TermQuery( t );
- classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
- }
- BooleanQuery filteredQuery = new BooleanQuery();
- filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
- filteredQuery.add( classFilter, BooleanClause.Occur.MUST );
- return filteredQuery;
- }
- }
-
- private int max(int first, Hits hits) {
- return maxResults == null ?
- hits.length() - 1 :
- maxResults + first < hits.length() ?
- first + maxResults - 1 :
- hits.length() - 1;
- }
-
- private int first() {
- return firstResult != null ?
- firstResult :
- 0;
- }
-
- //TODO change classesAndSubclasses by side effect, which is a mismatch with the Searcher return, fix that.
- private Searcher buildSearcher(LuceneEventListener listener) {
- Map<Class, DocumentBuilder<Object>> builders = listener.getDocumentBuilders();
- Set<Directory> directories = new HashSet<Directory>();
- if ( classes == null || classes.length == 0 ) {
- //no class means all classes
- for ( DocumentBuilder builder : builders.values() ) {
- directories.add( builder.getDirectoryProvider().getDirectory() );
- }
- classesAndSubclasses = null;
- }
- else {
- Set<Class> involvedClasses = new HashSet<Class>( classes.length );
- Collections.addAll( involvedClasses, classes );
- for ( Class clazz : classes ) {
- DocumentBuilder builder = builders.get( clazz );
- if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
- }
- for ( Class clazz : involvedClasses ) {
- DocumentBuilder builder = builders.get( clazz );
- //TODO should we rather choose a polymorphic path and allow non mapped entities
- if ( builder == null ) throw new HibernateException( "Not a mapped entity: " + clazz );
- directories.add( builder.getDirectoryProvider().getDirectory() );
- }
- classesAndSubclasses = involvedClasses;
- }
-
- //set up the searcher
- Searcher searcher;
- int dirNbr = directories.size();
- if ( dirNbr > 1 ) {
- try {
- IndexSearcher[] searchers = new IndexSearcher[dirNbr];
- Iterator<Directory> it = directories.iterator();
- for ( int index = 0; index < dirNbr; index++ ) {
- searchers[index] = new IndexSearcher( it.next() );
- }
- searcher = new MultiSearcher( searchers );
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to read Lucene directory", e );
- }
- }
- else {
- try {
- searcher = new IndexSearcher( directories.iterator().next() );
- }
- catch (IOException e) {
- throw new HibernateException( "Unable to read Lucene directory", e );
- }
- }
- return searcher;
- }
-
- private void setResultSize(Hits hits) {
- resultSize = hits.length();
- }
-
- //FIXME does it make sense
- public int resultSize() {
- return this.resultSize;
- }
-
- public Query setFirstResult(int firstResult) {
- this.firstResult = firstResult;
- return this;
- }
-
- public Query setMaxResults(int maxResults) {
- this.maxResults = maxResults;
- return this;
- }
-
- public int executeUpdate() throws HibernateException {
- throw new HibernateException( "Not supported operation" );
- }
-
- public Query setLockMode(String alias, LockMode lockMode) {
- return null;
- }
-
- protected Map getLockModes() {
- return null;
- }
-}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -18,7 +18,7 @@
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.search.engine.DocumentBuilder;
-import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.event.FullTextEventListener;
import org.hibernate.type.Type;
/**
@@ -31,11 +31,11 @@
private final int max;
private int current;
private final Session session;
- private final LuceneEventListener listener;
+ private final FullTextEventListener listener;
private EntityInfo[] entityInfos;
public ScrollableResultsImpl(
- Searcher searcher, Hits hits, int first, int max, Session session, LuceneEventListener listener
+ Searcher searcher, Hits hits, int first, int max, Session session, FullTextEventListener listener
) {
this.searcher = searcher;
this.hits = hits;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -4,20 +4,20 @@
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.event.FullTextEventListener;
/**
* @author Emmanuel Bernard
*/
public abstract class ContextHelper {
- public static LuceneEventListener getLuceneEventListener(SessionImplementor session) {
+ public static FullTextEventListener getLuceneEventListener(SessionImplementor session) {
PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
- LuceneEventListener listener = null;
+ FullTextEventListener listener = null;
//FIXME this sucks since we mandante the event listener use
for ( PostInsertEventListener candidate : listeners ) {
- if ( candidate instanceof LuceneEventListener ) {
- listener = (LuceneEventListener) candidate;
+ if ( candidate instanceof FullTextEventListener ) {
+ listener = (FullTextEventListener) candidate;
break;
}
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -19,7 +19,7 @@
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.event.FullTextEventListener;
/**
* @author Gavin King
@@ -183,7 +183,7 @@
cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
cfg.setProperty( "hibernate.search.Clock.directory_provider", FSDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- LuceneEventListener del = new LuceneEventListener();
+ FullTextEventListener del = new FullTextEventListener();
cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del} );
cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del} );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -8,12 +8,9 @@
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
import org.hibernate.search.store.RAMDirectoryProvider;
-import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.event.FullTextEventListener;
import org.hibernate.HibernateException;
-import org.hibernate.SessionFactory;
import org.hibernate.impl.SessionFactoryImpl;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.SessionFactoryImplementor;
/**
* @author Emmanuel Bernard
@@ -28,13 +25,13 @@
return getLuceneEventListener().getDocumentBuilders().get( clazz ).getDirectoryProvider().getDirectory();
}
- private LuceneEventListener getLuceneEventListener() {
+ private FullTextEventListener getLuceneEventListener() {
PostInsertEventListener[] listeners = ( (SessionFactoryImpl) getSessions() ).getEventListeners().getPostInsertEventListeners();
- LuceneEventListener listener = null;
+ FullTextEventListener listener = null;
//FIXME this sucks since we mandante the event listener use
for (PostInsertEventListener candidate : listeners) {
- if (candidate instanceof LuceneEventListener) {
- listener = (LuceneEventListener) candidate;
+ if (candidate instanceof FullTextEventListener ) {
+ listener = (FullTextEventListener) candidate;
break;
}
}
@@ -45,7 +42,7 @@
protected void configure(org.hibernate.cfg.Configuration cfg) {
cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- LuceneEventListener del = new LuceneEventListener();
+ FullTextEventListener del = new FullTextEventListener();
cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del} );
cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del} );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -1,21 +1,10 @@
//$Id: $
package org.hibernate.search.test;
-import java.io.File;
import java.io.IOException;
import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.search.LuceneSession;
-import org.hibernate.search.event.LuceneEventListener;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.TermDocs;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.store.Directory;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -11,13 +11,11 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.search.test.TestCase;
-import org.hibernate.search.LuceneSession;
+import org.hibernate.search.FullTextSession;
import org.hibernate.search.Environment;
-import org.hsqldb.Session;
import org.apache.lucene.search.Query;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
/**
@@ -43,7 +41,7 @@
tx.commit();
tx = s.beginTransaction();
- LuceneSession session = new LuceneSession(s);
+ FullTextSession session = new FullTextSession(s);
QueryParser parser = new QueryParser("id", new StandardAnalyzer() );
Query query;
List result;
@@ -73,7 +71,7 @@
tx.commit();
tx = s.beginTransaction();
- LuceneSession session = new LuceneSession(s);
+ FullTextSession session = new FullTextSession(s);
QueryParser parser = new QueryParser("id", new SimpleAnalyzer() );
Query query;
List result;
@@ -115,7 +113,7 @@
tx.commit();
tx = s.beginTransaction();
- LuceneSession session = new LuceneSession(s);
+ FullTextSession session = new FullTextSession(s);
QueryParser parser = new QueryParser("id", new StandardAnalyzer() );
Query query;
List result;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -4,7 +4,7 @@
import java.util.List;
import org.hibernate.search.test.TestCase;
-import org.hibernate.search.LuceneSession;
+import org.hibernate.search.FullTextSession;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.apache.lucene.queryParser.QueryParser;
@@ -24,7 +24,7 @@
s.clear();
- LuceneSession session = new LuceneSession(s);
+ FullTextSession session = new FullTextSession(s);
tx = session.beginTransaction();
QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
List result = session.createLuceneQuery( p.parse( "Abstract:Hibernate" ) ).list();
@@ -48,7 +48,7 @@
s.clear();
- LuceneSession session = new LuceneSession(s);
+ FullTextSession session = new FullTextSession(s);
tx = session.beginTransaction();
QueryParser p = new QueryParser("id", new StandardAnalyzer( ) );
List result = session.createLuceneQuery( p.parse( "title:Action OR Abstract:Action" ) ).list();
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -2,18 +2,13 @@
package org.hibernate.search.test.inheritance;
import org.hibernate.search.test.TestCase;
-import org.hibernate.search.test.query.Clock;
-import org.hibernate.search.test.query.Book;
-import org.hibernate.search.LuceneSession;
+import org.hibernate.search.FullTextSession;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.ScrollableResults;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.search.Query;
import java.util.List;
-import java.util.Iterator;
/**
* @author Emmanuel Bernard
@@ -21,7 +16,7 @@
public class InheritanceTest extends TestCase {
public void testInheritance() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Animal a = new Animal();
a.setName("Shark Jr");
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -5,7 +5,7 @@
import java.util.Iterator;
import org.hibernate.search.test.TestCase;
-import org.hibernate.search.LuceneSession;
+import org.hibernate.search.FullTextSession;
import org.hibernate.Transaction;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
@@ -20,7 +20,7 @@
public class LuceneQueryTest extends TestCase {
public void testList() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Clock clock = new Clock(1, "Seiko");
s.save( clock );
@@ -62,7 +62,7 @@
}
public void testFirstMax() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Clock clock = new Clock(1, "Seiko");
s.save( clock );
@@ -108,7 +108,7 @@
}
public void testIterator() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Clock clock = new Clock(1, "Seiko");
s.save( clock );
@@ -145,7 +145,7 @@
}
public void testScrollableResultSet() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Clock clock = new Clock(1, "Seiko");
s.save( clock );
@@ -188,7 +188,7 @@
}
public void testMultipleEntityPerIndex() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
Clock clock = new Clock(1, "Seiko");
s.save( clock );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java 2006-11-07 01:03:16 UTC (rev 10742)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java 2006-11-07 01:16:53 UTC (rev 10743)
@@ -1,12 +1,10 @@
//$Id: $
package org.hibernate.search.test.session;
-import java.sql.SQLException;
import java.util.List;
import org.hibernate.search.test.TestCase;
-import org.hibernate.search.LuceneSession;
-import org.hibernate.Session;
+import org.hibernate.search.FullTextSession;
import org.hibernate.Transaction;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.analysis.StopAnalyzer;
@@ -17,7 +15,7 @@
public class MassIndexTest extends TestCase {
public void testTransactional() throws Exception {
- LuceneSession s = new LuceneSession( openSession() );
+ FullTextSession s = new FullTextSession( openSession() );
Transaction tx = s.beginTransaction();
int loop = 4;
for (int i = 0 ; i < loop; i++) {
@@ -29,13 +27,13 @@
tx.commit();
s.close();
- s = new LuceneSession( openSession() );
+ s = new FullTextSession( openSession() );
s.getTransaction().begin();
s.connection().createStatement().executeUpdate( "update Email set body='Meet the guys who write the software'");
s.getTransaction().commit();
s.close();
- s = new LuceneSession( openSession() );
+ s = new FullTextSession( openSession() );
tx = s.beginTransaction();
QueryParser parser = new QueryParser("id", new StopAnalyzer() );
List result = s.createLuceneQuery( parser.parse( "body:write" ) ).list();
@@ -51,7 +49,7 @@
tx.commit(); //do the process
s.close();
- s = new LuceneSession( openSession() );
+ s = new FullTextSession( openSession() );
tx = s.beginTransaction();
result = s.createLuceneQuery( parser.parse( "body:write" ) ).list();
assertEquals( loop, result.size() );
18 years, 2 months
Hibernate SVN: r10742 - in branches/Lucene_Integration/HibernateExt/metadata/src: java/org/hibernate java/org/hibernate/search java/org/hibernate/search/annotations java/org/hibernate/search/backend java/org/hibernate/search/backend/impl java/org/hibernate/search/bridge java/org/hibernate/search/engine java/org/hibernate/search/event java/org/hibernate/search/query java/org/hibernate/search/store java/org/hibernate/search/util test/org/hibernate test/org/hibernate/search/test test/org/hi
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-06 20:03:16 -0500 (Mon, 06 Nov 2006)
New Revision: 10742
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/test/lucene/
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/Environment.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Boost.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DocumentId.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Field.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Index.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Indexed.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Keyword.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Store.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Text.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Unstored.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/AddWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/DeleteWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/UpdateWork.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Work.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/WorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Workspace.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/BatchLuceneWorkQueue.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/LuceneWorker.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigDecimalBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigIntegerBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DateBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DoubleBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FloatBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IdFieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IntegerBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/LongBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/NumberBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/ParameterizedBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/Resolution.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2IdFieldBridgeAdaptor.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringImplBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/EntityInfo.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/IteratorImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/FSDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/RAMDirectoryProvider.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/BinderHelper.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/AlternateDocument.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Clock.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/RamDirectoryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/Cloud.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateFieldBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateStringBridge.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/Document.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Animal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Mammal.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/AlternateBook.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Book.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Clock.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/Email.java
branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java
Log:
ANN-488 package change lucene => search
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search (from rev 10741, branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene)
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/Environment.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/Environment.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/Environment.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene;
+package org.hibernate.search;
/**
* @author Emmanuel Bernard
@@ -8,10 +8,10 @@
/**
* Indexes base directory
*/
- public static final String INDEX_BASE_DIR = "hibernate.lucene.index_dir";
+ public static final String INDEX_BASE_DIR = "hibernate.search.index_dir";
/**
* Lucene analyser
*/
- public static final String ANALYZER_CLASS = "hibernate.lucene.analyzer";
+ public static final String ANALYZER_CLASS = "hibernate.search.analyzer";
}
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/LuceneSession.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/LuceneSession.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene;
+package org.hibernate.search;
import java.io.Serializable;
import java.sql.Connection;
@@ -27,16 +27,16 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.impl.SessionImpl;
-import org.hibernate.lucene.query.LuceneQueryImpl;
-import org.hibernate.lucene.event.LuceneEventListener;
-import org.hibernate.lucene.util.ContextHelper;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.backend.UpdateWork;
-import org.hibernate.lucene.backend.Work;
-import org.hibernate.lucene.backend.WorkQueue;
-import org.hibernate.lucene.backend.impl.BatchLuceneWorkQueue;
-import org.hibernate.lucene.backend.impl.PostTransactionWorkQueueSynchronization;
-import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.search.query.LuceneQueryImpl;
+import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.util.ContextHelper;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.type.Type;
import org.apache.lucene.document.Document;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Boost.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Boost.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Boost.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DateBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DateBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DateBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -7,7 +7,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.hibernate.lucene.bridge.Resolution;
+import org.hibernate.search.bridge.Resolution;
/**
* Defines the temporal resolution of a given field
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DocumentId.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/DocumentId.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/DocumentId.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -10,7 +10,7 @@
/**
* Declare a field as the document id. If set to a property, the property will be used
* TODO: If set to a class, the class itself will be passed to the FieldBridge
- * Note that @{link org.hibernate.lucene.bridge.FieldBridge#get} must return the Entity id
+ * Note that @{link org.hibernate.search.bridge.FieldBridge#get} must return the Entity id
*
* @author Emmanuel Bernard
*/
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Field.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Field.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Field.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -3,7 +3,7 @@
* JavaDoc copy/pastle from the Apache Lucene project
* Available under the ASL 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/FieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/FieldBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/FieldBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Index.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Index.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Index.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
/**
* Defines how an Field should be indexed
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Indexed.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Indexed.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Indexed.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Keyword.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Keyword.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Keyword.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Store.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Store.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Store.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
/**
* Whether or not the value is stored in the document
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Text.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Text.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Text.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Unstored.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/annotations/Unstored.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/annotations/Unstored.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.annotations;
+package org.hibernate.search.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/AddWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/AddWork.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/AddWork.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
import java.io.Serializable;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/DeleteWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/DeleteWork.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/DeleteWork.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
import java.io.Serializable;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/UpdateWork.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/UpdateWork.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/UpdateWork.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
import java.io.Serializable;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Work.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Work.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Work.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
import java.io.Serializable;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/WorkQueue.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/WorkQueue.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
/**
* Set of work operations
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/Workspace.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/Workspace.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend;
+package org.hibernate.search.backend;
import java.io.IOException;
import java.util.ArrayList;
@@ -13,8 +13,8 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.hibernate.HibernateException;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.store.DirectoryProvider;
/**
* Lucene workspace
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/BatchLuceneWorkQueue.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/BatchLuceneWorkQueue.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/BatchLuceneWorkQueue.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,20 +1,20 @@
//$Id: $
-package org.hibernate.lucene.backend.impl;
+package org.hibernate.search.backend.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-import org.hibernate.lucene.backend.impl.LuceneWorker;
-import org.hibernate.lucene.backend.WorkQueue;
-import org.hibernate.lucene.backend.Workspace;
-import org.hibernate.lucene.backend.Work;
-import org.hibernate.lucene.backend.UpdateWork;
-import org.hibernate.lucene.backend.DeleteWork;
-import org.hibernate.lucene.backend.AddWork;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.backend.impl.LuceneWorker;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.Workspace;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.DeleteWork;
+import org.hibernate.search.backend.AddWork;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/LuceneWorker.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/LuceneWorker.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/LuceneWorker.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.backend.impl;
+package org.hibernate.search.backend.impl;
import java.io.IOException;
import java.io.Serializable;
@@ -13,12 +13,12 @@
import org.apache.lucene.index.TermDocs;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.backend.Workspace;
-import org.hibernate.lucene.backend.DeleteWork;
-import org.hibernate.lucene.backend.AddWork;
-import org.hibernate.lucene.backend.UpdateWork;
-import org.hibernate.lucene.backend.Work;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.backend.Workspace;
+import org.hibernate.search.backend.DeleteWork;
+import org.hibernate.search.backend.AddWork;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.Work;
/**
* Stateless implementation that perform a work
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/backend/impl/PostTransactionWorkQueueSynchronization.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,11 +1,11 @@
//$Id: $
-package org.hibernate.lucene.backend.impl;
+package org.hibernate.search.backend.impl;
import javax.transaction.Status;
import javax.transaction.Synchronization;
-import org.hibernate.lucene.backend.WorkQueue;
-import org.hibernate.lucene.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.Work;
/**
* Execute some work inside a transaction sychronization
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigDecimalBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigDecimalBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigDecimalBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import java.math.BigDecimal;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigIntegerBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BigIntegerBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BigIntegerBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import java.math.BigInteger;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/BridgeFactory.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -56,20 +56,20 @@
builtInBridges.put( BigDecimal.class.getName(), BIG_DECIMAL );
builtInBridges.put( String.class.getName(), STRING );
- DATE_YEAR = org.hibernate.lucene.bridge.DateBridge.DATE_YEAR;
- DATE_MONTH = org.hibernate.lucene.bridge.DateBridge.DATE_MONTH;
- DATE_DAY = org.hibernate.lucene.bridge.DateBridge.DATE_DAY;
- DATE_HOUR = org.hibernate.lucene.bridge.DateBridge.DATE_HOUR;
- DATE_MINUTE = org.hibernate.lucene.bridge.DateBridge.DATE_MINUTE;
- DATE_SECOND = org.hibernate.lucene.bridge.DateBridge.DATE_SECOND;
- DATE_MILLISECOND = org.hibernate.lucene.bridge.DateBridge.DATE_MILLISECOND;
+ DATE_YEAR = org.hibernate.search.bridge.DateBridge.DATE_YEAR;
+ DATE_MONTH = org.hibernate.search.bridge.DateBridge.DATE_MONTH;
+ DATE_DAY = org.hibernate.search.bridge.DateBridge.DATE_DAY;
+ DATE_HOUR = org.hibernate.search.bridge.DateBridge.DATE_HOUR;
+ DATE_MINUTE = org.hibernate.search.bridge.DateBridge.DATE_MINUTE;
+ DATE_SECOND = org.hibernate.search.bridge.DateBridge.DATE_SECOND;
+ DATE_MILLISECOND = org.hibernate.search.bridge.DateBridge.DATE_MILLISECOND;
builtInBridges.put( Date.class.getName(), DATE_MILLISECOND );
}
public static FieldBridge guessType(XMember member) {
FieldBridge bridge = null;
- org.hibernate.lucene.annotations.FieldBridge bridgeAnn =
- member.getAnnotation( org.hibernate.lucene.annotations.FieldBridge.class );
+ org.hibernate.search.annotations.FieldBridge bridgeAnn =
+ member.getAnnotation( org.hibernate.search.annotations.FieldBridge.class );
if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
try {
@@ -93,9 +93,9 @@
throw new HibernateException( "Unable to instanciate FieldBridge for " + member.getName(), e );
}
}
- else if ( member.isAnnotationPresent( org.hibernate.lucene.annotations.DateBridge.class ) ) {
- Resolution resolution = member.getAnnotation( org.hibernate.lucene.annotations.DateBridge.class ).value();
- bridge = org.hibernate.lucene.bridge.DateBridge.getDateField( resolution );
+ else if ( member.isAnnotationPresent( org.hibernate.search.annotations.DateBridge.class ) ) {
+ Resolution resolution = member.getAnnotation( org.hibernate.search.annotations.DateBridge.class ).value();
+ bridge = org.hibernate.search.bridge.DateBridge.getDateField( resolution );
}
else {
//find in built-ins
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DateBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DateBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import java.text.ParseException;
import java.util.Date;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DoubleBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DoubleBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/DoubleBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.hibernate.util.StringHelper;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FieldBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FieldBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FloatBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/FloatBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/FloatBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.hibernate.util.StringHelper;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IdFieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IdFieldBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IdFieldBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.apache.lucene.document.Document;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IntegerBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/IntegerBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/IntegerBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.hibernate.util.StringHelper;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/LongBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/LongBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/LongBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.hibernate.util.StringHelper;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/NumberBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/NumberBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/NumberBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/ParameterizedBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/ParameterizedBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/ParameterizedBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import java.util.Map;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/Resolution.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/Resolution.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/Resolution.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
/**
* Date indexing resolution
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2IdFieldBridgeAdaptor.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/String2IdFieldBridgeAdaptor.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
/**
* Transform an object into a stirng representation and vice versa
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringImplBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/StringImplBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/bridge/StringImplBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.bridge;
+package org.hibernate.search.bridge;
/**
* Map a string element
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/engine/DocumentBuilder.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/engine/DocumentBuilder.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.engine;
+package org.hibernate.search.engine;
import java.io.Serializable;
import java.lang.reflect.Modifier;
@@ -16,19 +16,19 @@
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.cfg.annotations.Version;
-import org.hibernate.lucene.annotations.Boost;
-import org.hibernate.lucene.annotations.DocumentId;
-import org.hibernate.lucene.annotations.Index;
-import org.hibernate.lucene.annotations.Keyword;
-import org.hibernate.lucene.annotations.Store;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Unstored;
-import org.hibernate.lucene.bridge.BridgeFactory;
-import org.hibernate.lucene.bridge.FieldBridge;
-import org.hibernate.lucene.bridge.IdFieldBridge;
-import org.hibernate.lucene.event.LuceneEventListener;
-import org.hibernate.lucene.store.DirectoryProvider;
-import org.hibernate.lucene.util.BinderHelper;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Keyword;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Unstored;
+import org.hibernate.search.bridge.BridgeFactory;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.IdFieldBridge;
+import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.util.BinderHelper;
import org.hibernate.reflection.ReflectionManager;
import org.hibernate.reflection.XAnnotatedElement;
import org.hibernate.reflection.XClass;
@@ -162,8 +162,8 @@
idBoost = getBoost( member );
}
- org.hibernate.lucene.annotations.Field fieldAnn =
- member.getAnnotation( org.hibernate.lucene.annotations.Field.class );
+ org.hibernate.search.annotations.Field fieldAnn =
+ member.getAnnotation( org.hibernate.search.annotations.Field.class );
if ( fieldAnn != null ) {
setAccessible( member );
fieldGetters.add( member );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/event/LuceneEventListener.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/event/LuceneEventListener.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id$
-package org.hibernate.lucene.event;
+package org.hibernate.search.event;
import java.io.Serializable;
import java.util.HashMap;
@@ -25,18 +25,18 @@
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEvent;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.backend.AddWork;
-import org.hibernate.lucene.backend.DeleteWork;
-import org.hibernate.lucene.backend.UpdateWork;
-import org.hibernate.lucene.backend.Work;
-import org.hibernate.lucene.backend.WorkQueue;
-import org.hibernate.lucene.backend.impl.BatchLuceneWorkQueue;
-import org.hibernate.lucene.backend.impl.PostTransactionWorkQueueSynchronization;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.store.DirectoryProvider;
-import org.hibernate.lucene.store.DirectoryProviderFactory;
+import org.hibernate.search.Environment;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.backend.AddWork;
+import org.hibernate.search.backend.DeleteWork;
+import org.hibernate.search.backend.UpdateWork;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkQueue;
+import org.hibernate.search.backend.impl.BatchLuceneWorkQueue;
+import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.DirectoryProviderFactory;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.reflection.ReflectionManager;
import org.hibernate.reflection.XClass;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/EntityInfo.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/EntityInfo.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/EntityInfo.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.query;
+package org.hibernate.search.query;
import java.io.Serializable;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/IteratorImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/IteratorImpl.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/IteratorImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.query;
+package org.hibernate.search.query;
import java.util.Iterator;
import java.util.List;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/LuceneQueryImpl.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/LuceneQueryImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.query;
+package org.hibernate.search.query;
import java.io.IOException;
import java.io.Serializable;
@@ -34,9 +34,9 @@
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.impl.AbstractQueryImpl;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.event.LuceneEventListener;
-import org.hibernate.lucene.util.ContextHelper;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.event.LuceneEventListener;
+import org.hibernate.search.util.ContextHelper;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/query/ScrollableResultsImpl.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.query;
+package org.hibernate.search.query;
import java.io.IOException;
import java.math.BigDecimal;
@@ -17,8 +17,8 @@
import org.hibernate.HibernateException;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
-import org.hibernate.lucene.engine.DocumentBuilder;
-import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.event.LuceneEventListener;
import org.hibernate.type.Type;
/**
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProvider.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProvider.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.store;
+package org.hibernate.search.store;
import java.util.Properties;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/DirectoryProviderFactory.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.store;
+package org.hibernate.search.store;
import java.util.ArrayList;
import java.util.List;
@@ -9,7 +9,7 @@
import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
-import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.search.annotations.Indexed;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.reflection.ReflectionManager;
import org.hibernate.reflection.XClass;
@@ -20,13 +20,13 @@
* Create a Lucene directory provider
* <p/>
* Lucene directory providers are configured through properties
- * - hibernate.lucene.default.* and
- * - hibernate.lucene.<indexname>.*
+ * - hibernate.search.default.* and
+ * - hibernate.search.<indexname>.*
* <p/>
* <indexname> properties have precedence over default
* <p/>
* The implementation is described by
- * hibernate.lucene.[default|indexname].directory_provider
+ * hibernate.search.[default|indexname].directory_provider
* <p/>
* If none is defined the default value is FSDirectory
*
@@ -35,7 +35,7 @@
*/
public class DirectoryProviderFactory {
public List<DirectoryProvider<?>> providers = new ArrayList<DirectoryProvider<?>>();
- private static String LUCENE_PREFIX = "hibernate.lucene.";
+ private static String LUCENE_PREFIX = "hibernate.search.";
private static String LUCENE_DEFAULT = LUCENE_PREFIX + "default.";
private static String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/FSDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/FSDirectoryProvider.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/FSDirectoryProvider.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.store;
+package org.hibernate.search.store;
import java.io.File;
import java.io.IOException;
@@ -15,7 +15,7 @@
/**
* Use a Lucene FSDirectory
- * The base directory is represented by hibernate.lucene.<index>.indexBase
+ * The base directory is represented by hibernate.search.<index>.indexBase
* The index is created in <base directory>/<index name>
*
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/RAMDirectoryProvider.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/store/RAMDirectoryProvider.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/store/RAMDirectoryProvider.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.store;
+package org.hibernate.search.store;
import java.io.IOException;
import java.util.Properties;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/BinderHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/BinderHelper.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/BinderHelper.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.util;
+package org.hibernate.search.util;
import org.hibernate.reflection.XMember;
import org.hibernate.util.StringHelper;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/util/ContextHelper.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/search/util/ContextHelper.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,10 +1,10 @@
//$Id: $
-package org.hibernate.lucene.util;
+package org.hibernate.search.util;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.search.event.LuceneEventListener;
/**
* @author Emmanuel Bernard
Copied: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search (from rev 10741, branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene)
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/AlternateDocument.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/AlternateDocument.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/AlternateDocument.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,16 +1,16 @@
//$Id: $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.DocumentId;
-import org.hibernate.lucene.annotations.Field;
-import org.hibernate.lucene.annotations.Store;
-import org.hibernate.lucene.annotations.Index;
-import org.hibernate.lucene.annotations.Boost;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Boost;
/**
* Example of 2 entities mapped in the same index
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Clock.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Clock.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Clock.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,12 +1,12 @@
//$Id: $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Keyword;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/Document.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/Document.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,17 +1,17 @@
//$Id$
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Boost;
-import org.hibernate.lucene.annotations.Field;
-import org.hibernate.lucene.annotations.Index;
-import org.hibernate.lucene.annotations.DocumentId;
-import org.hibernate.lucene.annotations.Store;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Store;
@Entity
@Indexed(index = "Documents")
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/FSDirectoryTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/FSDirectoryTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: LuceneTest.java 10014 2006-06-12 09:56:27 -0700 (lun., 12 juin 2006) epbernard $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import java.io.File;
import java.util.List;
@@ -17,9 +17,9 @@
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.store.FSDirectoryProvider;
-import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.search.Environment;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.event.LuceneEventListener;
/**
* @author Gavin King
@@ -180,8 +180,8 @@
protected void configure(org.hibernate.cfg.Configuration cfg) {
File sub = getBaseIndexDir();
- cfg.setProperty( "hibernate.lucene.default.indexBase", sub.getAbsolutePath() );
- cfg.setProperty( "hibernate.lucene.Clock.directory_provider", FSDirectoryProvider.class.getName() );
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( "hibernate.search.Clock.directory_provider", FSDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
LuceneEventListener del = new LuceneEventListener();
cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/RamDirectoryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/RamDirectoryTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/RamDirectoryTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import java.io.File;
import java.util.List;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/TestCase.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TestCase.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,14 +1,14 @@
//$Id: $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.store.Directory;
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.lucene.Environment;
-import org.hibernate.lucene.store.RAMDirectoryProvider;
-import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.search.Environment;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.event.LuceneEventListener;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.impl.SessionFactoryImpl;
@@ -43,7 +43,7 @@
}
protected void configure(org.hibernate.cfg.Configuration cfg) {
- cfg.setProperty( "hibernate.lucene.default.directory_provider", RAMDirectoryProvider.class.getName() );
+ cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
LuceneEventListener del = new LuceneEventListener();
cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/TransactionTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/TransactionTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.test;
+package org.hibernate.search.test;
import java.io.File;
import java.io.IOException;
@@ -7,8 +7,8 @@
import org.hibernate.Session;
import org.hibernate.HibernateException;
import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.lucene.LuceneSession;
-import org.hibernate.lucene.event.LuceneEventListener;
+import org.hibernate.search.LuceneSession;
+import org.hibernate.search.event.LuceneEventListener;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.TermDocs;
import org.apache.lucene.index.Term;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/BridgeTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/BridgeTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,5 +1,5 @@
//$Id: $
-package org.hibernate.lucene.test.bridge;
+package org.hibernate.search.test.bridge;
import java.util.Date;
import java.util.List;
@@ -10,9 +10,9 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.lucene.test.TestCase;
-import org.hibernate.lucene.LuceneSession;
-import org.hibernate.lucene.Environment;
+import org.hibernate.search.test.TestCase;
+import org.hibernate.search.LuceneSession;
+import org.hibernate.search.Environment;
import org.hsqldb.Session;
import org.apache.lucene.search.Query;
import org.apache.lucene.queryParser.QueryParser;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/Cloud.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/Cloud.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/Cloud.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,17 +1,17 @@
//$Id: $
-package org.hibernate.lucene.test.bridge;
+package org.hibernate.search.test.bridge;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import org.hibernate.lucene.annotations.Keyword;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.DateBridge;
-import org.hibernate.lucene.annotations.FieldBridge;
-import org.hibernate.lucene.bridge.Resolution;
+import org.hibernate.search.annotations.Keyword;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.FieldBridge;
+import org.hibernate.search.bridge.Resolution;
import org.hibernate.annotations.Parameter;
/**
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateFieldBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/TruncateFieldBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateFieldBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,7 +1,7 @@
//$Id: $
-package org.hibernate.lucene.test.bridge;
+package org.hibernate.search.test.bridge;
-import org.hibernate.lucene.bridge.FieldBridge;
+import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.util.StringHelper;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateStringBridge.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/bridge/TruncateStringBridge.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/bridge/TruncateStringBridge.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,10 +1,10 @@
//$Id: $
-package org.hibernate.lucene.test.bridge;
+package org.hibernate.search.test.bridge;
import java.util.Map;
-import org.hibernate.lucene.bridge.StringBridge;
-import org.hibernate.lucene.bridge.ParameterizedBridge;
+import org.hibernate.search.bridge.StringBridge;
+import org.hibernate.search.bridge.ParameterizedBridge;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/Document.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/Document.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/Document.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,16 +1,16 @@
//$Id: $
-package org.hibernate.lucene.test.fieldAccess;
+package org.hibernate.search.test.fieldAccess;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Entity;
import javax.persistence.Lob;
-import org.hibernate.lucene.annotations.Unstored;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Keyword;
-import org.hibernate.lucene.annotations.Boost;
-import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.search.annotations.Unstored;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Keyword;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.Indexed;
/**
* @author Richard Hallier
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/fieldAccess/FieldAccessTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/fieldAccess/FieldAccessTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,10 +1,10 @@
//$Id: $
-package org.hibernate.lucene.test.fieldAccess;
+package org.hibernate.search.test.fieldAccess;
import java.util.List;
-import org.hibernate.lucene.test.TestCase;
-import org.hibernate.lucene.LuceneSession;
+import org.hibernate.search.test.TestCase;
+import org.hibernate.search.LuceneSession;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.apache.lucene.queryParser.QueryParser;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Animal.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Animal.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Animal.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,9 +1,9 @@
//$Id: $
-package org.hibernate.lucene.test.inheritance;
+package org.hibernate.search.test.inheritance;
-import org.hibernate.lucene.annotations.Keyword;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Indexed;
+import org.hibernate.search.annotations.Keyword;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Indexed;
import javax.persistence.Entity;
import javax.persistence.Id;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/InheritanceTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/InheritanceTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,10 +1,10 @@
//$Id: $
-package org.hibernate.lucene.test.inheritance;
+package org.hibernate.search.test.inheritance;
-import org.hibernate.lucene.test.TestCase;
-import org.hibernate.lucene.test.query.Clock;
-import org.hibernate.lucene.test.query.Book;
-import org.hibernate.lucene.LuceneSession;
+import org.hibernate.search.test.TestCase;
+import org.hibernate.search.test.query.Clock;
+import org.hibernate.search.test.query.Book;
+import org.hibernate.search.LuceneSession;
import org.hibernate.Transaction;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Mammal.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/inheritance/Mammal.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/inheritance/Mammal.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,8 +1,8 @@
//$Id: $
-package org.hibernate.lucene.test.inheritance;
+package org.hibernate.search.test.inheritance;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Keyword;
import javax.persistence.Entity;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/AlternateBook.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/AlternateBook.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/AlternateBook.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,13 +1,13 @@
//$Id: $
-package org.hibernate.lucene.test.query;
+package org.hibernate.search.test.query;
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.DocumentId;
-import org.hibernate.lucene.annotations.Field;
-import org.hibernate.lucene.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Book.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Book.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Book.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,13 +1,13 @@
//$Id: $
-package org.hibernate.lucene.test.query;
+package org.hibernate.search.test.query;
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Keyword;
-import org.hibernate.lucene.annotations.Unstored;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Keyword;
+import org.hibernate.search.annotations.Unstored;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Clock.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/Clock.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/Clock.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,12 +1,12 @@
//$Id: $
-package org.hibernate.lucene.test.query;
+package org.hibernate.search.test.query;
import javax.persistence.Entity;
import javax.persistence.Id;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.Text;
-import org.hibernate.lucene.annotations.Keyword;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Text;
+import org.hibernate.search.annotations.Keyword;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/query/LuceneQueryTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/query/LuceneQueryTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,11 +1,11 @@
//$Id: $
-package org.hibernate.lucene.test.query;
+package org.hibernate.search.test.query;
import java.util.List;
import java.util.Iterator;
-import org.hibernate.lucene.test.TestCase;
-import org.hibernate.lucene.LuceneSession;
+import org.hibernate.search.test.TestCase;
+import org.hibernate.search.LuceneSession;
import org.hibernate.Transaction;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/Email.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/session/Email.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/Email.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,14 +1,14 @@
//$Id: $
-package org.hibernate.lucene.test.session;
+package org.hibernate.search.test.session;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import org.hibernate.lucene.annotations.Indexed;
-import org.hibernate.lucene.annotations.DocumentId;
-import org.hibernate.lucene.annotations.Field;
-import org.hibernate.lucene.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
/**
* @author Emmanuel Bernard
Modified: branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/lucene/test/session/MassIndexTest.java 2006-11-06 22:14:32 UTC (rev 10741)
+++ branches/Lucene_Integration/HibernateExt/metadata/src/test/org/hibernate/search/test/session/MassIndexTest.java 2006-11-07 01:03:16 UTC (rev 10742)
@@ -1,11 +1,11 @@
//$Id: $
-package org.hibernate.lucene.test.session;
+package org.hibernate.search.test.session;
import java.sql.SQLException;
import java.util.List;
-import org.hibernate.lucene.test.TestCase;
-import org.hibernate.lucene.LuceneSession;
+import org.hibernate.search.test.TestCase;
+import org.hibernate.search.LuceneSession;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.apache.lucene.queryParser.QueryParser;
18 years, 2 months