-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 19, 2010 5:30 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
I've a NullPointerException :

Code:
Exception in thread "Main Thread" java.lang.NullPointerException
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getIdentifierName(DocumentBuilderIndexedEntity.java:512)
   at org.hibernate.search.engine.ObjectLoaderHelper.initializeObjects(ObjectLoaderHelper.java:50)
   at org.hibernate.search.engine.QueryLoader.load(QueryLoader.java:42)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:284)
   at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:92)
   at xxx.GenericSearchDaoImpl.searchLucene(GenericSearchDaoImpl.java:56)
   at xxx.GenericSearchManagerMetierImpl.searchLuceneQuery(GenericSearchManagerMetierImpl.java:41)
   at xxx.xxxSearchManagerMetierTest.main(xxxSearchManagerMetierTest.java:36


I use a ProvidedId with FieldBridg because of composed Id

But TwoWayStringBridge use is correctly impl.

I use a PrimaryKey Class xxxPK

Code:
@ProvidedId(bridge=@FieldBridge(impl=xxx_ProvidedId_Bridge.class))


I look HS sources quickly in SVN but it doesn't give me an answer to revise my code.

thx for help.

G.S.


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Sat Mar 20, 2010 10:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
You misunderstand the meaning of @ProvidedId. @ProvidedId got to for example make JBossCache searchable. It is used if you are not working with persistent entities. If you have an hibernate/jpa managed entity just place an additional @FieldBridge annotation on the property which is annotated with @Id or @DocumentId.

--Hardy


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Sat Mar 20, 2010 12:01 pm 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
Ok, i'll try
Thx.

G. S.


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 26, 2010 6:55 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
No exception generate during process but no results return...

getResultSize() give me 15
getResultList().size() give me 0

I check id return by lucene from my bridge trace.
I check in my DB and data exist

getResultList() return nothing...


Debug :

Code:
List<T> resultList = q.getResultList();


i could see that resultList.elementData = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 26, 2010 10:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Can you post your annotated entities and the search query you are trying to execute? It i hard to diagnose the problem when you only provide pieces at the time ;-)

--Hardy


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 26, 2010 11:02 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
Entity :
Code:
@Indexed
@AnalyzerDefs({
   @AnalyzerDef(name="standardStopWords",
         tokenizer=
            @TokenizerDef(factory = StandardTokenizerFactory.class),
         filters = {
            @TokenFilterDef(factory = LowerCaseFilterFactory.class),
            @TokenFilterDef(factory = ISOLatin1AccentFilterFactory.class),
            @TokenFilterDef(factory = StopFilterFactory.class,
                  params={
                     @Parameter(name="words", value="StopWords.txt"),
                     @Parameter(name="ignoreCase", value="true")
                  }
            )
         }
   )
})
@Entity
public class Demande extends DemandeEntity {


Superclass :
Code:
@MappedSuperclass
public class DemandeEntity implements Serializable {

   @FieldBridge(impl=Demande_DocumentId_Bridge.class)
   @DocumentId
   @IndexedEmbedded
   private DemandePK demandePK;


Bridge :
Code:
public class Demande_DocumentId_Bridge implements TwoWayStringBridge {

   public Object stringToObject(String arg0) {
      String[] tab = arg0.split("þ");
      return new DemandePK(tab[0],tab[1],tab[2]);
   }

   public String objectToString(Object arg0) {
      DemandePK d = (DemandePK)arg0;
      return d.getUiPhar()+"þ"+d.getRdes()+"þ"+d.getTypeDem();
   }
}

TestClass :
Code:
public static void main(String[] args) {
      
      ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("META-INF/PostGreSQL-applicationContext.xml");
      GenericSearchManagerMetier demandeSearchManagerMetier = (GenericSearchManagerMetier) appContext.getBean("demandeSearchManagerMetier");
      
      String rqt = "+text:jean +text:francois";
      BeanLuceneQuery beanLuceneQuery = new BeanLuceneQuery(rqt);   
      BeanResultats br = null;
      
      try {
         br = demandeSearchManagerMetier.searchLuceneQuery(beanLuceneQuery,0,15);
      } catch (NegativeOrNullInteger e) {
         e.printStackTrace();
      }
      
      System.out.print("Nb total : "+br.getNbTotalResults()+"\n");
      System.out.print("Nb Résultats : "+br.getResults().size()+"\n");
      
   }

Lucene part of precess is alright !
Primary keys DemandePK generated by HS just before requesting DB are alright

but no return...

br.getNbTotalResults() return 16
but
br.getResults().size() return 0

Beans are correctly implemented.
I traced return of :
Code:
List<T> resultList = q.getResultList();

but list size = 0

stdout :
Code:
Hibernate: select this_ (..xxx..)  from Demande this_ where ((this_.RDES, this_.TYPE_DEM, this_.UI_PHAR) in ((?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?)))
Nb total : 16
Nb Résultats : 0


i see no problem in my code...
thx for help.

G. S.


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 26, 2010 2:38 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
It looks like there's a mismatch while creating the PK of your entity, and then it doesn't find the matching values in the DB.

I don't see how you mapped the demandePK field as primary key of your entity?

I would suggest you to write a simple test loading an entity from the database by primary key, and build this primary key using the stringToObject method from your bridge, to verify Hibernate can load this and the bridge is parsing your string correctly.

something like

Code:
Demande_DocumentId_Bridge bridge = new Demande_DocumentId_Bridge();
DemandePK demandePK = (DemandePK) bridge.stringToObject( "Test using a valid String here" );
Demande demande = entityManager.load(Demande.class, demandePK);
assert demande != null;


this has to work and verifies your mapping the the bridge, when doing a Lucene query it will load entities using the same bridge.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Fri Mar 26, 2010 3:24 pm 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
If it's that : shame on me.

I agree with your rational. Will see on Monday.

Thanks.
G. S.


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Mon Mar 29, 2010 2:25 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
I tested the bridge. it's alright.
Problem comes from elsewhere..

I think that it's provided by HS code. I don't know where.
If anyone see a solution i'll make also a JIRA request.

Thx for help.

G. S.


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Mon Mar 29, 2010 5:21 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
I made a JIRA request.

http://opensource.atlassian.com/project ... SEARCH-479

I'm creating a test project with same condition to remake bug and transmit to hibernate team


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Mon Mar 29, 2010 5:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
thank you, a test is definitely useful to understand this.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: search : NullPointerException in getIdentifierName
PostPosted: Mon Mar 29, 2010 7:16 am 
Beginner
Beginner

Joined: Fri Feb 05, 2010 10:54 am
Posts: 28
Clearly HS have a problem.
I make the simplest test project and i have no return when result size is upper than 1 !
Test Project is up.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.