[
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-444?pag...
]
Begot Gilles commented on HSEARCH-444:
--------------------------------------
In our project we use Teneo / Hibernate 3.6.0.Final to manipulate a MySql database and we
use Hibernate Search 3.3.0.Final to index data stored in database. We use entity-name in
XML mappings generated by teneo and in our java code. The patch for HSEARCH-444 is not
integrated in HibernateSearch 3.3.0.Final. Can you put this patch in the next version of
hibernate search?
Your patch allows us to initialize hibernate search. However, our application fails when
we post a query with hibernate search:
java.lang.NullPointerException
at
org.hibernate.search.engine.ObjectLoaderHelper.executeLoad(ObjectLoaderHelper.java:144)
at
org.hibernate.search.engine.ObjectLoaderHelper.returnAlreadyLoadedObjectsInCorrectOrder(ObjectLoaderHelper.java:124)
at org.hibernate.search.engine.QueryLoader.executeLoad(QueryLoader.java:81)
at org.hibernate.search.engine.AbstractLoader.load(AbstractLoader.java:70)
at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:317)
The function getClassMetadata return null because we use entity-name in
ObjectLoaderHelper.java:144.
or our application, i have modified the code of executeLoad like this (for example if
indexed class is com.ExampleImpl -> teneo chooses Example for entity-name):
private static Object executeLoad(EntityInfo entityInfo, Session session) {
Object maybeProxy;
ClassMetadata metadata = session.getSessionFactory().getClassMetadata( entityInfo.clazz
);
String entity_name = null;
if (metadata==null) {
int indexLastPoint = entityInfo.clazz.getName().lastIndexOf(".");
String lastSegment;
if (indexLastPoint!=-1)
lastSegment = entityInfo.clazz.getName().substring(indexLastPoint+1);
else
lastSegment = entityInfo.clazz.getName();
int indexImpl = lastSegment.indexOf("Impl");
if (indexImpl!=-1)
entity_name = lastSegment.substring(0, indexImpl);
else
entity_name = lastSegment;
metadata = session.getSessionFactory().getClassMetadata( entity_name );
}
String hibernateIdentifierProperty = metadata.getIdentifierPropertyName();
if ( entityInfo.idName.equals( hibernateIdentifierProperty ) ) {
//be sure to get an initialized object but save from ONFE and ENFE
if (entity_name==null)
maybeProxy = session.load( entityInfo.clazz, entityInfo.id );
else
maybeProxy = session.load( entity_name, entityInfo.id );
}
else {
Criteria criteria = session.createCriteria( entityInfo.clazz );
criteria.add( Restrictions.eq( entityInfo.idName, entityInfo.id ) );
try {
maybeProxy = criteria.uniqueResult();
}
catch ( HibernateException e ) {
throw new SearchException(
"Loading entity of type " + entityInfo.clazz.getName() + " using
'"
+ entityInfo.idName
+ "' as document id and '"
+ entityInfo.id
+ "' as value was not unique"
);
}
}
return maybeProxy;
}
But the best correction would be to access directly to XML mapping to get the entity-name.
But we must modify API...
Search fails to start when core uses XML mappings making use of
entity-name attribute
-------------------------------------------------------------------------------------
Key: HSEARCH-444
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-444
Project: Hibernate Search
Issue Type: Bug
Components: mapping
Affects Versions: 3.1.0.GA
Reporter: Sanne Grinovero
Assignee: Emmanuel Bernard
Attachments: HSEARCH-444_partial_1-1_bridge_between_entity-name_and_class.patch
As described on forums:
https://forum.hibernate.org/viewtopic.php?f=9&t=993687
classes mapped using XML on hibernate core, like
classes starting with:
<class name="com.mydomain.myapp.AnswerImpl" table="answer"
entity-name="Answer">
cause:
Caused by: java.lang.NullPointerException
at
org.hibernate.search.cfg.SearchConfigurationFromHibernateCore.getClassMapping(SearchConfigurationFromHibernateCore.java:31)
at
org.hibernate.search.store.DirectoryProviderFactory.getDirectoryProviderName(DirectoryProviderFactory.java:226)
at
org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProviders(DirectoryProviderFactory.java:53)
at
org.hibernate.search.impl.SearchFactoryImpl.initDocumentBuilders(SearchFactoryImpl.java:404)
at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:119)
at
org.hibernate.search.event.ContextHolder.getOrBuildSearchFactory(ContextHolder.java:30)
at
org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:59)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 16 more
This was reported on 3.1.0.GA but I guess it affects all releases.
There's a "test WAR" in the forums, going to ask for a testcase.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira