Author: epbernard
Date: 2008-03-30 11:58:44 -0400 (Sun, 30 Mar 2008)
New Revision: 14484
Modified:
search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java
search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java
Log:
Fix the composite id test
Modified: search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java 2008-03-27
23:10:46 UTC (rev 14483)
+++ search/trunk/src/test/org/hibernate/search/test/id/EmbeddedIdTest.java 2008-03-30
15:58:44 UTC (rev 14484)
@@ -30,6 +30,16 @@
List results = Search.createFullTextSession( s ).createFullTextQuery(
new TermQuery( new Term("id.lastName", "Bernard" ) ) ).list();
assertEquals( 1, results.size() );
+ emm = (Person) results.get(0);
+ emm.setFavoriteColor( "Red" );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ results = Search.createFullTextSession( s ).createFullTextQuery(
+ new TermQuery( new Term("id.lastName", "Bernard" ) ) ).list();
+ assertEquals( 1, results.size() );
+ emm = (Person) results.get(0);
+ assertEquals( "Red", emm.getFavoriteColor() );
s.delete( results.get( 0 ) );
tx.commit();
s.close();
Modified: search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java 2008-03-27
23:10:46 UTC (rev 14483)
+++ search/trunk/src/test/org/hibernate/search/test/id/PersonPKBridge.java 2008-03-30
15:58:44 UTC (rev 14484)
@@ -28,11 +28,18 @@
public void set(String name, Object value, Document document, Field.Store store,
Field.Index index, Field.TermVector termVector, Float boost) {
PersonPK id = (PersonPK) value;
+
+ //store each property in a unique field
Field field = new Field( name + ".firstName", id.getFirstName(), store,
index, termVector );
if ( boost != null ) field.setBoost( boost );
document.add( field );
field = new Field( name + ".lastName", id.getLastName(), store, index,
termVector );
if ( boost != null ) field.setBoost( boost );
document.add( field );
+
+ //store the unique string representation in the named field
+ field = new Field( name, objectToString( id ), store, index, termVector );
+ if ( boost != null ) field.setBoost( boost );
+ document.add( field );
}
}
Show replies by date