Hibernate SVN: r19140 - core/trunk/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-30 09:15:29 -0400 (Tue, 30 Mar 2010)
New Revision: 19140
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
Log:
HHH-5049 org.hibernate.test.legacy.ParentChildTest error running testLoadAfterNonExists with Ingres
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2010-03-30 10:11:40 UTC (rev 19139)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2010-03-30 13:15:29 UTC (rev 19140)
@@ -26,6 +26,7 @@
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.engine.EntityEntry;
import org.hibernate.impl.SessionImpl;
@@ -1034,8 +1035,8 @@
public void testLoadAfterNonExists() throws HibernateException, SQLException {
Session session = openSession();
- if ( (getDialect() instanceof MySQLDialect) ) {
- session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+ if ( ( getDialect() instanceof MySQLDialect ) || ( getDialect() instanceof IngresDialect ) ) {
+ session.connection().setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED );
}
session.getTransaction().begin();
14 years, 9 months
Hibernate SVN: r19139 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-30 06:11:40 -0400 (Tue, 30 Mar 2010)
New Revision: 19139
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AvailableSettings.java
Log:
Add comment on why some settings use the org.hibernate prefix while others don't
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AvailableSettings.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AvailableSettings.java 2010-03-30 03:24:37 UTC (rev 19138)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AvailableSettings.java 2010-03-30 10:11:40 UTC (rev 19139)
@@ -203,6 +203,7 @@
* by a dot. For example<code>Query.setHint( "org.hibernate.lockMode.a", someLockMode )</code>
* would apply <code>someLockMode</code> to the alias <code>"a"</code>.
*/
+ //Use the org.hibernate prefix. instead of hibernate. as it is a query hint se QueryHints
public static final String ALIAS_SPECIFIC_LOCK_MODE = "org.hibernate.lockMode";
/**
@@ -272,6 +273,7 @@
/**
* Used to determine flush mode.
*/
+ //Use the org.hibernate prefix. instead of hibernate. as it is a query hint se QueryHints
public static final String FLUSH_MODE = "org.hibernate.flushMode";
/**
14 years, 9 months
Hibernate SVN: r19138 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-03-29 23:24:37 -0400 (Mon, 29 Mar 2010)
New Revision: 19138
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/readonly.xml
Log:
Fixed some DOS line endings which were breaking the jDocBook build
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/readonly.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/readonly.xml 2010-03-30 01:37:23 UTC (rev 19137)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/readonly.xml 2010-03-30 03:24:37 UTC (rev 19138)
@@ -412,8 +412,7 @@
<para>
To throw away non-flushed changes and make the persistent entity
- consistent with its database representation, call:
- </para>
+ consistent with its database representation, call: </para>
<programlisting role="Java">session.refresh( entity );</programlisting>
<para>
14 years, 9 months
Hibernate SVN: r19137 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-03-29 21:37:23 -0400 (Mon, 29 Mar 2010)
New Revision: 19137
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
Log:
HHH-4870 - Cannot determine java-type from given member [null]
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2010-03-30 01:05:18 UTC (rev 19136)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2010-03-30 01:37:23 UTC (rev 19137)
@@ -83,9 +83,12 @@
*/
@SuppressWarnings({ "unchecked" })
public <X, Y> AttributeImplementor<X, Y> buildAttribute(AbstractManagedType<X> ownerType, Property property) {
+ if ( isVirtual( property, ownerType ) ) {
+ // hide virtual properties (fabricated by Hibernate) from the JPA metamodel.
+ log.trace( "Skipping virtual property {}({})", ownerType.getJavaType().getName(), property.getName() );
+ return null;
+ }
log.trace( "Building attribute [{}.{}]", ownerType.getJavaType().getName(), property.getName() );
- //a back ref is a virtual property created by Hibernate, let's hide it from the JPA model.
- if ( property.isBackRef() ) return null;
final AttributeContext<X> attributeContext = wrap( ownerType, property );
final AttributeMetadata<X,Y> attributeMetadata =
determineAttributeMetadata( attributeContext, NORMAL_MEMBER_RESOLVER );
@@ -111,6 +114,12 @@
}
}
+ private <X> boolean isVirtual(Property property, AbstractManagedType<X> ownerType) {
+ // back-refs and embedded components are considered virtual
+ return property.isBackRef()
+ || ( property.isComposite() && ( (Component) property.getValue() ).isEmbedded() );
+ }
+
private <X> AttributeContext<X> wrap(final AbstractManagedType<X> ownerType, final Property property) {
return new AttributeContext<X>() {
public AbstractManagedType<X> getOwnerType() {
14 years, 9 months
Hibernate SVN: r19136 - in core/trunk: testsuite/src/test/java/org/hibernate/test/hql and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-03-29 21:05:18 -0400 (Mon, 29 Mar 2010)
New Revision: 19136
Modified:
core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/orphan/one2one/pk/unidirectional/DeleteOneToOneOrphansTest.java
Log:
HHH-2088 : TypeMismatchException on object equality expression from one-to-one relationship
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java 2010-03-30 00:56:45 UTC (rev 19135)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java 2010-03-30 01:05:18 UTC (rev 19136)
@@ -23,6 +23,7 @@
*/
package org.hibernate.hql.ast.tree;
+import org.hibernate.type.OneToOneType;
import org.hibernate.type.Type;
import org.hibernate.Hibernate;
import org.hibernate.TypeMismatchException;
@@ -80,8 +81,8 @@
// resolve an expected type
SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
if ( lhsType != null && rhsType != null ) {
- int lhsColumnSpan = lhsType.getColumnSpan( sessionFactory );
- if ( lhsColumnSpan != rhsType.getColumnSpan( sessionFactory ) ) {
+ int lhsColumnSpan = getColumnSpan( lhsType, sessionFactory );
+ if ( lhsColumnSpan != getColumnSpan( rhsType, sessionFactory ) ) {
throw new TypeMismatchException(
"left and right hand sides of a binary logic operator were incompatibile [" +
lhsType.getName() + " : "+ rhsType.getName() + "]"
@@ -97,6 +98,14 @@
}
}
+ private int getColumnSpan(Type type, SessionFactoryImplementor sfi) {
+ int columnSpan = type.getColumnSpan( sfi );
+ if ( columnSpan == 0 && type instanceof OneToOneType ) {
+ columnSpan = ( ( OneToOneType ) type ).getIdentifierOrUniqueKeyType( sfi ).getColumnSpan( sfi );
+ }
+ return columnSpan;
+ }
+
/**
* Mutate the subtree relating to a row-value-constructor to instead use
* a series of ANDed predicates. This allows multi-column type comparisons
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2010-03-30 00:56:45 UTC (rev 19135)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2010-03-30 01:05:18 UTC (rev 19136)
@@ -565,6 +565,32 @@
return count;
}
+ public void testEntityAndOneToOneReturnedByQuery() {
+ Session s = openSession();
+ s.beginTransaction();
+ Human h = new Human();
+ h.setName( new Name( "Gail", null, "Badner" ) );
+ s.save( h );
+ User u = new User();
+ u.setUserName( "gbadner" );
+ u.setHuman( h );
+ s.save( u );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ Object [] result = ( Object [] ) s.createQuery( "from User u, Human h where u.human = h" ).uniqueResult();
+ assertNotNull( result );
+ assertEquals( u.getUserName(), ( ( User ) result[ 0 ] ).getUserName() );
+ assertEquals( h.getName().getFirst(), ( ( Human ) result[ 1 ] ).getName().getFirst() );
+ assertSame( ( ( User ) result[ 0 ] ).getHuman(), result[ 1 ] );
+ s.createQuery( "delete User" ).executeUpdate();
+ s.createQuery( "delete Human" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testNestedComponentIsNull() {
// (1) From MapTest originally...
// (2) Was then moved into HQLTest...
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/orphan/one2one/pk/unidirectional/DeleteOneToOneOrphansTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/orphan/one2one/pk/unidirectional/DeleteOneToOneOrphansTest.java 2010-03-30 00:56:45 UTC (rev 19135)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/orphan/one2one/pk/unidirectional/DeleteOneToOneOrphansTest.java 2010-03-30 01:05:18 UTC (rev 19136)
@@ -72,6 +72,12 @@
assertEquals( 1, results.size() );
Employee emp = ( Employee ) results.get( 0 );
assertNotNull( emp.getInfo() );
+ results = session.createQuery( "from Employee e, EmployeeInfo i where e.info = i" ).list();
+ assertEquals( 1, results.size() );
+ Object [] result = ( Object [] ) results.get( 0 );
+ emp = ( Employee ) result[ 0 ];
+ assertNotNull( result[ 1 ] );
+ assertSame( emp.getInfo(), result[ 1 ] );
emp.setInfo( null );
session.getTransaction().commit();
session.close();
14 years, 9 months
Hibernate SVN: r19135 - core/trunk/documentation/manual/src/main/docbook/en-US.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-03-29 20:56:45 -0400 (Mon, 29 Mar 2010)
New Revision: 19135
Removed:
core/trunk/documentation/manual/src/main/docbook/en-US/misty.xml
Log:
Taking away test file
Deleted: core/trunk/documentation/manual/src/main/docbook/en-US/misty.xml
===================================================================
14 years, 9 months
Hibernate SVN: r19134 - core/trunk/documentation/manual/src/main/docbook/en-US.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-03-29 20:56:14 -0400 (Mon, 29 Mar 2010)
New Revision: 19134
Added:
core/trunk/documentation/manual/src/main/docbook/en-US/misty.xml
Log:
Testing commit access
Added: core/trunk/documentation/manual/src/main/docbook/en-US/misty.xml
===================================================================
14 years, 9 months
Hibernate SVN: r19133 - in core/branches/Branch_3_3: testsuite/src/test/java/org/hibernate/test/hql and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-03-29 20:45:45 -0400 (Mon, 29 Mar 2010)
New Revision: 19133
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
HHH-2088 : TypeMismatchException on object equality expression from one-to-one relationship
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java 2010-03-29 22:47:23 UTC (rev 19132)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java 2010-03-30 00:45:45 UTC (rev 19133)
@@ -23,6 +23,7 @@
*/
package org.hibernate.hql.ast.tree;
+import org.hibernate.type.OneToOneType;
import org.hibernate.type.Type;
import org.hibernate.Hibernate;
import org.hibernate.TypeMismatchException;
@@ -80,8 +81,8 @@
// resolve an expected type
SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
if ( lhsType != null && rhsType != null ) {
- int lhsColumnSpan = lhsType.getColumnSpan( sessionFactory );
- if ( lhsColumnSpan != rhsType.getColumnSpan( sessionFactory ) ) {
+ int lhsColumnSpan = getColumnSpan( lhsType, sessionFactory );
+ if ( lhsColumnSpan != getColumnSpan( rhsType, sessionFactory ) ) {
throw new TypeMismatchException(
"left and right hand sides of a binary logic operator were incompatibile [" +
lhsType.getName() + " : "+ rhsType.getName() + "]"
@@ -97,6 +98,14 @@
}
}
+ private int getColumnSpan(Type type, SessionFactoryImplementor sfi) {
+ int columnSpan = type.getColumnSpan( sfi );
+ if ( columnSpan == 0 && type instanceof OneToOneType ) {
+ columnSpan = ( ( OneToOneType ) type ).getIdentifierOrUniqueKeyType( sfi ).getColumnSpan( sfi );
+ }
+ return columnSpan;
+ }
+
/**
* Mutate the subtree relating to a row-value-constructor to instead use
* a series of ANDed predicates. This allows multi-column type comparisons
Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2010-03-29 22:47:23 UTC (rev 19132)
+++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java 2010-03-30 00:45:45 UTC (rev 19133)
@@ -391,6 +391,32 @@
return count;
}
+ public void testEntityAndOneToOneReturnedByQuery() {
+ Session s = openSession();
+ s.beginTransaction();
+ Human h = new Human();
+ h.setName( new Name( "Gail", null, "Badner" ) );
+ s.save( h );
+ User u = new User();
+ u.setUserName( "gbadner" );
+ u.setHuman( h );
+ s.save( u );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ Object [] result = ( Object [] ) s.createQuery( "from User u, Human h where u.human = h" ).uniqueResult();
+ assertNotNull( result );
+ assertEquals( u.getUserName(), ( ( User ) result[ 0 ] ).getUserName() );
+ assertEquals( h.getName().getFirst(), ( ( Human ) result[ 1 ] ).getName().getFirst() );
+ assertSame( ( ( User ) result[ 0 ] ).getHuman(), result[ 1 ] );
+ s.createQuery( "delete User" ).executeUpdate();
+ s.createQuery( "delete Human" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testNestedComponentIsNull() {
// (1) From MapTest originally...
// (2) Was then moved into HQLTest...
14 years, 9 months
Hibernate SVN: r19132 - in search/trunk/hibernate-search/src/test/java/org/hibernate/search/test: embedded and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-29 18:47:23 -0400 (Mon, 29 Mar 2010)
New Revision: 19132
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java
Removed:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Event.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/ParentOfBirthEvent.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Person.java
Log:
HSEARCH-476 Work queue contains the same operation multiple times and some add/delete operations have null primary keys (moving tests to appropriate package)
Copied: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph (from rev 19129, search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch)
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Event.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Event.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Event.java 2010-03-29 22:47:23 UTC (rev 19132)
@@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.search.test.scratch;
+package org.hibernate.search.test.embedded.graph;
import java.io.Serializable;
import java.util.HashSet;
Property changes on: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Event.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/ParentOfBirthEvent.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/ParentOfBirthEvent.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/ParentOfBirthEvent.java 2010-03-29 22:47:23 UTC (rev 19132)
@@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.search.test.scratch;
+package org.hibernate.search.test.embedded.graph;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
Property changes on: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/ParentOfBirthEvent.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Person.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Person.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Person.java 2010-03-29 22:47:23 UTC (rev 19132)
@@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.search.test.scratch;
+package org.hibernate.search.test.embedded.graph;
import java.io.Serializable;
import java.util.HashSet;
Property changes on: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java 2010-03-29 22:47:23 UTC (rev 19132)
@@ -1,115 +0,0 @@
-/* $Id$
- *
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
- *
- * 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, as published by the Free Software Foundation.
- *
- * 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
- */
-package org.hibernate.search.test.scratch;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TopDocs;
-import org.hibernate.Session;
-import org.hibernate.search.test.SearchTestCase;
-
-public class RecursiveGraphTest extends SearchTestCase {
-
- public void testCreateParentAndChild() throws Exception {
- Person[] people = new Person[2];
- Person parent = new Person();
- parent.setName( "parent" );
- Person child = new Person();
- child.setName( "child" );
- connectChildToParent(child, parent);
- people[0] = parent;
- people[1] = child;
- savePeople( people );
- showIndexContentsForType( Person.class );
- assertEquals( 2, getDocumentNbr( Person.class ) );
- }
-
- private void connectChildToParent(Person child, Person parent) {
- Event birthEvent = child.getBirthEvent();
- child.setBirthEvent(birthEvent);
- ParentOfBirthEvent parentOfBirthEvent = new ParentOfBirthEvent(parent, child.getBirthEvent());
- parent.getParentOfBirthEvents().add(parentOfBirthEvent);
- }
-
- public void savePeople(Person... people) {
- for (Person person : people) {
- if (person==null) continue;
- Session s = getSessions().openSession();
- s.getTransaction().begin();
- s.save( person );
- s.getTransaction().commit();
- s.close();
- }
- }
-
- @Override
- protected Class<?>[] getMappings() {
- return new Class[]{
- Event.class,
- Person.class,
- ParentOfBirthEvent.class
- };
- }
-
- private int getDocumentNbr(Class type) throws Exception {
- IndexReader reader = IndexReader.open( getDirectory( type ), false );
- try {
- return reader.numDocs();
- }
- finally {
- reader.close();
- }
- }
-
- private void showIndexContentsForType(Class type) throws CorruptIndexException, IOException {
- IndexSearcher searcher = new IndexSearcher( getDirectory( type ), false );
- try {
- Query q = new MatchAllDocsQuery();
- TopDocs docs = searcher.search( q, null, 100 );
- ScoreDoc[] scoreDocs = docs.scoreDocs;
- for (ScoreDoc sd : scoreDocs) {
- Document doc = searcher.doc( sd.doc );
- StringBuilder sb = new StringBuilder();
- for (Fieldable field : (List<Fieldable>)doc.getFields()) {
- sb.append( field.name() ).append( ":" ).append( field.stringValue() ).append( " " );
- }
- //System.out.println( sb.toString() );
- }
- }
- finally {
- searcher.close();
- }
- }
-
-}
Copied: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java (from rev 19131, search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java)
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java 2010-03-29 22:47:23 UTC (rev 19132)
@@ -0,0 +1,87 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * 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
+ */
+package org.hibernate.search.test.embedded.graph;
+
+import org.apache.lucene.index.IndexReader;
+import org.hibernate.Session;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * TestCase to verify proper management of saving of complex relations and collections.
+ * See HSEARCH-476
+ */
+public class RecursiveGraphTest extends SearchTestCase {
+
+ public void testCreateParentAndChild() throws Exception {
+ Person[] people = new Person[2];
+ Person parent = new Person();
+ parent.setName( "parent" );
+ Person child = new Person();
+ child.setName( "child" );
+ connectChildToParent(child, parent);
+ people[0] = parent;
+ people[1] = child;
+ savePeople( people );
+ assertEquals( 2, getDocumentNbr( Person.class ) );
+ }
+
+ private void connectChildToParent(Person child, Person parent) {
+ Event birthEvent = child.getBirthEvent();
+ child.setBirthEvent(birthEvent);
+ ParentOfBirthEvent parentOfBirthEvent = new ParentOfBirthEvent(parent, child.getBirthEvent());
+ parent.getParentOfBirthEvents().add(parentOfBirthEvent);
+ }
+
+ public void savePeople(Person... people) {
+ for (Person person : people) {
+ if (person==null) continue;
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.save( person );
+ s.getTransaction().commit();
+ s.close();
+ }
+ }
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class[]{
+ Event.class,
+ Person.class,
+ ParentOfBirthEvent.class
+ };
+ }
+
+ private int getDocumentNbr(Class type) throws Exception {
+ IndexReader reader = IndexReader.open( getDirectory( type ), false );
+ try {
+ return reader.numDocs();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+}
Property changes on: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/graph/RecursiveGraphTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
14 years, 9 months
Hibernate SVN: r19131 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-29 18:37:08 -0400 (Mon, 29 Mar 2010)
New Revision: 19131
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
Log:
remove dead code from RecursiveGraphTest
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 22:35:23 UTC (rev 19130)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 22:37:08 UTC (rev 19131)
@@ -24,21 +24,16 @@
*/
package org.hibernate.search.test.scratch;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TopDocs;
import org.hibernate.Session;
import org.hibernate.search.test.SearchTestCase;
+/**
+ * TestCase to verify proper management of saving of complex relations and collections.
+ * See HSEARCH-476
+ *
+ * @author Sanne Grinovero
+ */
public class RecursiveGraphTest extends SearchTestCase {
public void testCreateParentAndChild() throws Exception {
@@ -51,7 +46,6 @@
people[0] = parent;
people[1] = child;
savePeople( people );
- showIndexContentsForType( Person.class );
assertEquals( 2, getDocumentNbr( Person.class ) );
}
@@ -92,24 +86,4 @@
}
}
- private void showIndexContentsForType(Class type) throws CorruptIndexException, IOException {
- IndexSearcher searcher = new IndexSearcher( getDirectory( type ), false );
- try {
- Query q = new MatchAllDocsQuery();
- TopDocs docs = searcher.search( q, null, 100 );
- ScoreDoc[] scoreDocs = docs.scoreDocs;
- for (ScoreDoc sd : scoreDocs) {
- Document doc = searcher.doc( sd.doc );
- StringBuilder sb = new StringBuilder();
- for (Fieldable field : (List<Fieldable>)doc.getFields()) {
- sb.append( field.name() ).append( ":" ).append( field.stringValue() ).append( " " );
- }
- //System.out.println( sb.toString() );
- }
- }
- finally {
- searcher.close();
- }
- }
-
}
14 years, 9 months