Hibernate SVN: r14416 - core/trunk/core.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-03-09 23:26:11 -0400 (Sun, 09 Mar 2008)
New Revision: 14416
Modified:
core/trunk/core/pom.xml
Log:
update antlr-maven-plugin to release version 2.1
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2008-03-10 03:17:31 UTC (rev 14415)
+++ core/trunk/core/pom.xml 2008-03-10 03:26:11 UTC (rev 14416)
@@ -141,7 +141,7 @@
</reporting>
<properties>
- <antlrPluginVersion>2.1-SNAPSHOT</antlrPluginVersion>
+ <antlrPluginVersion>2.1</antlrPluginVersion>
</properties>
</project>
16 years, 9 months
Hibernate SVN: r14415 - core/trunk.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-03-09 23:17:31 -0400 (Sun, 09 Mar 2008)
New Revision: 14415
Modified:
core/trunk/pom.xml
Log:
temporarily disable the documentation module from the release profile
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-03-10 03:15:17 UTC (rev 14414)
+++ core/trunk/pom.xml 2008-03-10 03:17:31 UTC (rev 14415)
@@ -64,9 +64,12 @@
as well as execution of the assembly plugin (to build the SourceForge dist).
-->
<id>release</id>
+<!--
+ temporarily disable documentation module
<modules>
<module>documentation</module>
</modules>
+-->
<build>
<plugins>
<plugin>
16 years, 9 months
Hibernate SVN: r14414 - maven-poms/trunk/core-manual-parent.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-03-09 23:15:17 -0400 (Sun, 09 Mar 2008)
New Revision: 14414
Modified:
maven-poms/trunk/core-manual-parent/pom.xml
Log:
copyright header
Modified: maven-poms/trunk/core-manual-parent/pom.xml
===================================================================
--- maven-poms/trunk/core-manual-parent/pom.xml 2008-03-09 18:20:32 UTC (rev 14413)
+++ maven-poms/trunk/core-manual-parent/pom.xml 2008-03-10 03:15:17 UTC (rev 14414)
@@ -1,19 +1,28 @@
<?xml version="1.0"?>
<!--
- ~ Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ ~ Hibernate, Relational Persistence for Idiomatic Java
~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
~ This copyrighted material is made available to anyone wishing to use, modify,
~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, v. 2.1. This program is distributed in the
- ~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- ~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ~ Lesser General Public License for more details. You should have received a
- ~ copy of the GNU Lesser General Public License, v.2.1 along with this
- ~ distribution; if not, write to the Free Software Foundation, Inc.,
- ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ~ Lesser General Public License, as published by the Free Software Foundation.
~
- ~ Red Hat Author(s): Steve Ebersole
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16 years, 9 months
Hibernate SVN: r14413 - tags/TOOLS_3_2_1_GA/HibernateExt.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-03-09 14:20:32 -0400 (Sun, 09 Mar 2008)
New Revision: 14413
Added:
tags/TOOLS_3_2_1_GA/HibernateExt/Branch_3_2/
Log:
proper release for jboss tools 2.0.1
Copied: tags/TOOLS_3_2_1_GA/HibernateExt/Branch_3_2 (from rev 14412, branches/Branch_3_2)
16 years, 9 months
Hibernate SVN: r14412 - tags/TOOLS_3_2_1_GA.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-03-09 14:19:36 -0400 (Sun, 09 Mar 2008)
New Revision: 14412
Added:
tags/TOOLS_3_2_1_GA/HibernateExt/
Log:
16 years, 9 months
Hibernate SVN: r14411 - tags.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-03-09 14:18:23 -0400 (Sun, 09 Mar 2008)
New Revision: 14411
Added:
tags/TOOLS_3_2_1_GA/
Log:
16 years, 9 months
Hibernate SVN: r14410 - in branches/Branch_3_2/HibernateExt/tools: src/java/org/hibernate/tool and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-03-09 14:08:11 -0400 (Sun, 09 Mar 2008)
New Revision: 14410
Modified:
branches/Branch_3_2/HibernateExt/tools/build.xml
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
Log:
do a proper release.
Modified: branches/Branch_3_2/HibernateExt/tools/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/build.xml 2008-03-09 17:04:52 UTC (rev 14409)
+++ branches/Branch_3_2/HibernateExt/tools/build.xml 2008-03-09 18:08:11 UTC (rev 14410)
@@ -7,7 +7,7 @@
<!-- Name of project and version, used to create filenames -->
<property name="Name" value="Hibernate Tools"/>
<property name="name" value="hibernate-tools"/>
- <property name="version" value="3.2.0.GA"/>
+ <property name="version" value="3.2.1.GA"/>
<property name="javadoc.packagenames" value="org.hibernate.tool"/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2008-03-09 17:04:52 UTC (rev 14409)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2008-03-09 18:08:11 UTC (rev 14410)
@@ -5,7 +5,7 @@
final public class Version {
- public static final String VERSION = "3.2.0.GA";
+ public static final String VERSION = "3.2.1.GA";
private static final Version instance = new Version();
16 years, 9 months
Hibernate SVN: r14409 - in search/trunk/src: java/org/hibernate/search/bridge/builtin and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-03-09 13:04:52 -0400 (Sun, 09 Mar 2008)
New Revision: 14409
Added:
search/trunk/src/java/org/hibernate/search/bridge/builtin/ClassBridge.java
search/trunk/src/java/org/hibernate/search/bridge/builtin/UriBridge.java
search/trunk/src/java/org/hibernate/search/bridge/builtin/UrlBridge.java
Modified:
search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java
search/trunk/src/test/org/hibernate/search/test/bridge/BridgeTest.java
search/trunk/src/test/org/hibernate/search/test/bridge/Cloud.java
Log:
HSEARCH-164, HSEARCH-165 Class, URL, URI built-in bridges
Modified: search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java 2008-03-07 17:17:13 UTC (rev 14408)
+++ search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -6,6 +6,8 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.net.URL;
+import java.net.URI;
import org.hibernate.HibernateException;
import org.hibernate.AssertionFailure;
@@ -20,6 +22,8 @@
import org.hibernate.search.bridge.builtin.ShortBridge;
import org.hibernate.search.bridge.builtin.EnumBridge;
import org.hibernate.search.bridge.builtin.BooleanBridge;
+import org.hibernate.search.bridge.builtin.UrlBridge;
+import org.hibernate.search.bridge.builtin.UriBridge;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.Field;
@@ -58,6 +62,12 @@
public static final TwoWayFieldBridge BOOLEAN = new TwoWayString2FieldBridgeAdaptor( new BooleanBridge() );
+ public static final TwoWayFieldBridge CLAZZ = new TwoWayString2FieldBridgeAdaptor( new org.hibernate.search.bridge.builtin.ClassBridge() );
+
+ public static final TwoWayFieldBridge Url = new TwoWayString2FieldBridgeAdaptor( new UrlBridge() );
+
+ public static final TwoWayFieldBridge Uri = new TwoWayString2FieldBridgeAdaptor( new UriBridge() );
+
public static final FieldBridge DATE_YEAR = new String2FieldBridgeAdaptor( DateBridge.DATE_YEAR );
public static final FieldBridge DATE_MONTH = new String2FieldBridgeAdaptor( DateBridge.DATE_MONTH );
public static final FieldBridge DATE_DAY = new String2FieldBridgeAdaptor( DateBridge.DATE_DAY );
@@ -83,6 +93,9 @@
builtInBridges.put( String.class.getName(), STRING );
builtInBridges.put( Boolean.class.getName(), BOOLEAN );
builtInBridges.put( boolean.class.getName(), BOOLEAN );
+ builtInBridges.put( Class.class.getName(), CLAZZ );
+ builtInBridges.put( URL.class.getName(), Url );
+ builtInBridges.put( URI.class.getName(), Uri );
builtInBridges.put( Date.class.getName(), DATE_MILLISECOND );
}
Added: search/trunk/src/java/org/hibernate/search/bridge/builtin/ClassBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/builtin/ClassBridge.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/bridge/builtin/ClassBridge.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -0,0 +1,35 @@
+//$
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.search.bridge.TwoWayStringBridge;
+import org.hibernate.search.SearchException;
+import org.hibernate.annotations.common.util.StringHelper;
+import org.hibernate.annotations.common.util.ReflectHelper;
+
+/**
+ * Convert a Class back and forth
+ *
+ * @author Emmanuel Bernard
+ */
+public class ClassBridge implements TwoWayStringBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ else {
+ try {
+ return ReflectHelper.classForName( stringValue, ClassBridge.class );
+ }
+ catch (ClassNotFoundException e) {
+ throw new SearchException("Unable to deserialize Class: " + stringValue, e);
+ }
+ }
+ }
+
+ public String objectToString(Object object) {
+ return object == null ?
+ null :
+ ( (Class) object).getName();
+
+ }
+}
Added: search/trunk/src/java/org/hibernate/search/bridge/builtin/UriBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/builtin/UriBridge.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/bridge/builtin/UriBridge.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -0,0 +1,36 @@
+//$
+package org.hibernate.search.bridge.builtin;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.hibernate.annotations.common.util.StringHelper;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.bridge.TwoWayStringBridge;
+
+/**
+ * Bridge for <code>URI</code>
+ *
+ * @author Emmanuel Bernard
+ */
+public class UriBridge implements TwoWayStringBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ else {
+ try {
+ return new URI( stringValue );
+ }
+ catch (URISyntaxException e) {
+ throw new SearchException( "Unable to build URI: " + stringValue, e );
+ }
+ }
+ }
+
+ public String objectToString(Object object) {
+ return object == null ?
+ null :
+ object.toString();
+ }
+}
\ No newline at end of file
Added: search/trunk/src/java/org/hibernate/search/bridge/builtin/UrlBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/builtin/UrlBridge.java (rev 0)
+++ search/trunk/src/java/org/hibernate/search/bridge/builtin/UrlBridge.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -0,0 +1,36 @@
+//$
+package org.hibernate.search.bridge.builtin;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.hibernate.search.bridge.TwoWayStringBridge;
+import org.hibernate.search.SearchException;
+import org.hibernate.annotations.common.util.StringHelper;
+
+/**
+ * Bridge for <code>URL</code>
+ *
+ * @author Emmanuel Bernard
+ */
+public class UrlBridge implements TwoWayStringBridge {
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ else {
+ try {
+ return new URL(stringValue);
+ }
+ catch (MalformedURLException e) {
+ throw new SearchException("Unable to build URL: " + stringValue, e);
+ }
+ }
+ }
+
+ public String objectToString(Object object) {
+ return object == null ?
+ null :
+ object.toString();
+ }
+}
Modified: search/trunk/src/test/org/hibernate/search/test/bridge/BridgeTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/bridge/BridgeTest.java 2008-03-07 17:17:13 UTC (rev 14408)
+++ search/trunk/src/test/org/hibernate/search/test/bridge/BridgeTest.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -6,6 +6,8 @@
import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.TimeZone;
+import java.net.URI;
+import java.net.URL;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
@@ -15,9 +17,13 @@
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.index.Term;
/**
* @author Emmanuel Bernard
@@ -37,6 +43,9 @@
cloud.setString(null);
cloud.setType( CloudType.DOG );
cloud.setStorm( false );
+ cloud.setClazz( Cloud.class );
+ cloud.setUri( new URI("http://www.hibernate.org") );
+ cloud.setUrl( new URL("http://www.hibernate.org") );
org.hibernate.Session s = openSession();
Transaction tx = s.beginTransaction();
s.persist(cloud);
@@ -63,6 +72,18 @@
result = session.createFullTextQuery(query).setProjection( "type" ).list();
assertEquals( "Enum projection works", 1, result.size() ); //the query is dumb because restrictive
+ query = new TermQuery( new Term("clazz", Cloud.class.getName() ) );
+ result = session.createFullTextQuery(query).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+ assertEquals( "Clazz projection works", Cloud.class.getName(), ( (Class) ((Object[])result.get(0))[0] ).getName() );
+
+ BooleanQuery bQuery = new BooleanQuery();
+ bQuery.add( new TermQuery( new Term("uri", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+ bQuery.add( new TermQuery( new Term("url", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+
+ result = session.createFullTextQuery(bQuery).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+
s.delete( s.get( Cloud.class, cloud.getId() ) );
tx.commit();
s.close();
Modified: search/trunk/src/test/org/hibernate/search/test/bridge/Cloud.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/bridge/Cloud.java 2008-03-07 17:17:13 UTC (rev 14408)
+++ search/trunk/src/test/org/hibernate/search/test/bridge/Cloud.java 2008-03-09 17:04:52 UTC (rev 14409)
@@ -2,6 +2,8 @@
package org.hibernate.search.test.bridge;
import java.util.Date;
+import java.net.URL;
+import java.net.URI;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -44,7 +46,37 @@
private String customStringBridge;
private CloudType type;
private boolean storm;
+ private Class clazz;
+ private URL url;
+ private URI uri;
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public URL getUrl() {
+ return url;
+ }
+
+ public void setUrl(URL url) {
+ this.url = url;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ @Field(index=Index.UN_TOKENIZED, store=Store.YES)
+ public Class getClazz() {
+ return clazz;
+ }
+
+ public void setClazz(Class clazz) {
+ this.clazz = clazz;
+ }
+
@Field(index=Index.TOKENIZED, store=Store.YES)
@FieldBridge(impl = TruncateFieldBridge.class)
public String getCustomFieldBridge() {
16 years, 9 months
Hibernate SVN: r14408 - in search/trunk/src: java/org/hibernate/search/bridge and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-03-07 12:17:13 -0500 (Fri, 07 Mar 2008)
New Revision: 14408
Added:
search/trunk/src/test/org/hibernate/search/test/id/
search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java
search/trunk/src/test/org/hibernate/search/test/id/Person.java
search/trunk/src/test/org/hibernate/search/test/id/PersonPK.java
search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java
Modified:
search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java
search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java
Log:
HSEARCH-163 better BridgeFactory error messages
Modified: search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java 2008-03-07 16:47:02 UTC (rev 14407)
+++ search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -16,6 +16,7 @@
@Target( {ElementType.FIELD, ElementType.METHOD} )
@Documented
public @interface FieldBridge {
+ //defaault to embed @FieldBridge in @Field
public Class impl() default void.class;
public Parameter[] params() default {};
Modified: search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java 2008-03-07 16:47:02 UTC (rev 14407)
+++ search/trunk/src/java/org/hibernate/search/bridge/BridgeFactory.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -137,6 +137,8 @@
}
if ( bridgeAnn != null ) {
Class impl = bridgeAnn.impl();
+ if (impl == void.class)
+ throw new SearchException("@FieldBridge with no implementation class defined in: " + member.getName() );
try {
Object instance = impl.newInstance();
if ( FieldBridge.class.isAssignableFrom( impl ) ) {
@@ -149,6 +151,10 @@
else if ( org.hibernate.search.bridge.StringBridge.class.isAssignableFrom( impl ) ) {
bridge = new String2FieldBridgeAdaptor( (org.hibernate.search.bridge.StringBridge) instance );
}
+ else {
+ throw new SearchException("@FieldBridge implementation implements none of the field bridge interfaces: "
+ + impl + " in " + member.getName() );
+ }
if ( bridgeAnn.params().length > 0 && ParameterizedBridge.class.isAssignableFrom( impl ) ) {
Map params = new HashMap( bridgeAnn.params().length );
for ( Parameter param : bridgeAnn.params() ) {
Added: search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -0,0 +1,43 @@
+//$
+package org.hibernate.search.test.id;
+
+import java.util.List;
+
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.Search;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.index.Term;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class EmbeddedIdTest extends SearchTestCase {
+ public void testFieldBridge() throws Exception {
+ PersonPK emmPk = new PersonPK();
+ emmPk.setFirstName( "Emmanuel" );
+ emmPk.setLastName( "Bernard" );
+ Person emm = new Person();
+ emm.setFavoriteColor( "Blue" );
+ emm.setId( emmPk );
+ Session s = openSession( );
+ Transaction tx = s.beginTransaction();
+ s.save(emm);
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ List results = Search.createFullTextSession( s ).createFullTextQuery(
+ new TermQuery( new Term("id.lastName", "Bernard" ) ) ).list();
+ assertEquals( 1, results.size() );
+ s.delete( results.get( 0 ) );
+ tx.commit();
+ s.close();
+
+ }
+ protected Class[] getMappings() {
+ return new Class[] {
+ Person.class
+ };
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/id/Person.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/Person.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/id/Person.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -0,0 +1,40 @@
+//$
+package org.hibernate.search.test.id;
+
+import javax.persistence.Entity;
+import javax.persistence.EmbeddedId;
+
+import org.hibernate.search.annotations.FieldBridge;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Person {
+ @EmbeddedId
+ @FieldBridge(impl = PersonPKBridge.class)
+ @DocumentId
+ private PersonPK id;
+ private String favoriteColor;
+
+ public PersonPK getId() {
+ return id;
+ }
+
+ public void setId(PersonPK id) {
+ this.id = id;
+ }
+
+ @Field
+ public String getFavoriteColor() {
+ return favoriteColor;
+ }
+
+ public void setFavoriteColor(String favoriteColor) {
+ this.favoriteColor = favoriteColor;
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/id/PersonPK.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/PersonPK.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/id/PersonPK.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -0,0 +1,49 @@
+//$
+package org.hibernate.search.test.id;
+
+import java.io.Serializable;
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public class PersonPK implements Serializable {
+ private String firstName;
+ private String lastName;
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof PersonPK ) ) return false;
+
+ PersonPK personPK = (PersonPK) o;
+
+ if ( firstName != null ? !firstName.equals( personPK.firstName ) : personPK.firstName != null ) return false;
+ if ( lastName != null ? !lastName.equals( personPK.lastName ) : personPK.lastName != null ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = ( firstName != null ? firstName.hashCode() : 0 );
+ result = 31 * result + ( lastName != null ? lastName.hashCode() : 0 );
+ return result;
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java 2008-03-07 17:17:13 UTC (rev 14408)
@@ -0,0 +1,38 @@
+//$
+package org.hibernate.search.test.id;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.bridge.TwoWayFieldBridge;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class PersonPKBridge implements TwoWayFieldBridge {
+
+ public Object get(String name, Document document) {
+ PersonPK id = new PersonPK();
+ Field field = document.getField( name + ".firstName" );
+ id.setFirstName( field.stringValue() );
+ field = document.getField( name + ".lastName" );
+ id.setLastName( field.stringValue() );
+ return id;
+ }
+
+ public String objectToString(Object object) {
+ PersonPK id = (PersonPK) object;
+ StringBuilder sb = new StringBuilder();
+ sb.append( id.getFirstName() ).append( " " ).append( id.getLastName() );
+ return sb.toString();
+ }
+
+ public void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost) {
+ PersonPK id = (PersonPK) value;
+ Field field = new Field( name + ".firstName", id.getFirstName(), store, index );
+ if ( boost != null ) field.setBoost( boost );
+ document.add( field );
+ field = new Field( name + ".lastName", id.getLastName(), store, index );
+ if ( boost != null ) field.setBoost( boost );
+ document.add( field );
+ }
+}
16 years, 9 months
Hibernate SVN: r14407 - search/trunk/src/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-03-07 11:47:02 -0500 (Fri, 07 Mar 2008)
New Revision: 14407
Modified:
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
better comment
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-03-07 06:17:03 UTC (rev 14406)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-03-07 16:47:02 UTC (rev 14407)
@@ -156,7 +156,8 @@
bindClassAnnotation(prefix, propertiesMetadata, classBridgeAnn);
}
- //rejecting non properties because the object is loaded from Hibernate, so indexing a non property does not make sense
+ //rejecting non properties (ie regular methods) because the object is loaded from Hibernate,
+ // so indexing a non property does not make sense
List<XProperty> methods = currClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
for (XProperty method : methods) {
initializeMember( method, propertiesMetadata, isRoot, prefix, processedClasses );
16 years, 9 months