Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [Search] TransientObjectException when creating initial idx
PostPosted: Thu Apr 05, 2012 10:09 pm 
Newbie

Joined: Thu Apr 05, 2012 7:37 pm
Posts: 5
I'm using the following code to initialize my Hibernate Search index:

Code:
EntityManager em = ...
FullTextEntityManager fullTextEM = Search.getFullTextEntityManager(em);
fullTextEM.createIndexer().startAndWait();


Now when I execute this code, I'm getting the following exception:

Code:
o.h.s.e.i.LogErrorHandler - HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation
org.hibernate.TransientObjectException: cannot lock an unsaved transient instance: com.example.Foo


In this case, the com.example.Foo class does have a @Transient annotation for a field that is calculated, but I don't want to be stored. This class is also not annotated with @Indexed. Note that this error is only cropping up when I try to create the index. Using the code otherwise works properly.

I've even tried removing all my @Field annotations and only have a single class marked with the @Indexed annotation, but I still get the same exception. Can anyone offer any advice?

edit: Spelling


Last edited by jsvazic on Tue Apr 10, 2012 11:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Sat Apr 07, 2012 11:23 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2296
Location: Third rock from the Sun
Hi,
is this class embedded in the only @Indexed class using @IndexedEmbedded ? I'd be interested in knowing why it's indexed.

Could you share a simplified version of your entity which triggers the error ? (by removing all fields and mappings which are not needed, se can create a test from it). Ideally you could share a full functional test, there are examples of tests in the sources.

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


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Sat Apr 07, 2012 2:12 pm 
Newbie

Joined: Thu Apr 05, 2012 7:37 pm
Posts: 5
sanne.grinovero wrote:
Hi,
is this class embedded in the only @Indexed class using @IndexedEmbedded ? I'd be interested in knowing why it's indexed.

Could you share a simplified version of your entity which triggers the error ? (by removing all fields and mappings which are not needed, se can create a test from it). Ideally you could share a full functional test, there are examples of tests in the sources.


I'll try to get a less obfuscated version in a few days when I'm back at work. The odd thing is that the class that's being complained about is not being indexed and does not have either an @Field or @IndexEmbedded annotation on it at all. Over on SO, someone suggested that I use a {Cascade=PERSIST} on the Foo object within my main container (it has a @ManyToOne annotation on it presently) and that seemed to work around the problem.

I'll try to get a reproducible case ASAP to help track down the issue, since I really don't want us using LIKE statements for our searches.


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Mon Apr 09, 2012 10:16 pm 
Newbie

Joined: Thu Apr 05, 2012 7:37 pm
Posts: 5
Apologies for the delay, but I have managed to distil my problem to a simple Java application. You can find the relevant code on GitHub at:

https://github.com/jsvazic/hibernate-search-example

A few things to note:

  • This is a simpler version of my full app, but it provides an easy way to replicate the problem.
  • The Language enum is hard-coded, but in production this value is determined via some session properties that are not relevant here.
  • The system is using MySQL 5.5.19, and I have included a SQL script to generate the schema and populate with some dummy data.
  • I have not used foreign key constraints due to some fancy partitioning that is being done on the DB back-end. This is currently by design.

Any help would be appreciated. Like I said, if we can't get Hibernate search working then the other devs on the team will want to use LIKE statements, and I really want to avoid that. TIA.


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Mon Apr 16, 2012 11:12 am 
Newbie

Joined: Thu Apr 05, 2012 7:37 pm
Posts: 5
Bump. Any help? I'm still at a loss as to why something so relatively simple is causing such a problem.


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Tue Dec 04, 2012 8:00 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 208
Suddenly running into this one as well after updating to Hibernate ORM 4.1.7. Not sure if it's related


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Tue Dec 04, 2012 10:39 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 208
Nope, turns out it is a @Version attribute I had introduced but I forgot to make sure that all @Version values on existing records were not null. If they are you get this exception during massindexing and tomcat6 basically hangs.


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Sat Dec 08, 2012 3:22 am 
Newbie

Joined: Sat Dec 08, 2012 3:04 am
Posts: 1
Nice post. I like it. Thanks for sharing these information. Keep it up. :)

_________________
alton


Top
 Profile  
 
 Post subject: Re: [Search] TransientObjectException when creating initial idx
PostPosted: Tue Jan 21, 2014 6:48 am 
Newbie

Joined: Tue Jan 21, 2014 6:43 am
Posts: 1
I have tried executing the code you have shared here to initialize the Hibernate Search index, but as you were telling it throw an error. It seems that you have tried all possible solutions without any result. I think it is better you consult this question with a good programmer; he would be able to correct the code and execute it properly.



Thanks
CHRIS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 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.