-->
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: Depth of index update on @IndexedEmbedded
PostPosted: Fri Jun 03, 2011 4:10 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Hello everybody,

I have little bit complicated scenario of embded entities in parent index. I'll try to explain:

Code:
@Indexed @Entity
class A{
   @IndexedEmbedded
   @OneToMany(mappedBy="a", fetch=FetchType.LAZY)
   private List<B> bs;
}

@Entity
class B{
   @ContainedIn
   @ManyToOne(fetch=FetchType.LAZY)
   private A a;

   @IndexedEmbedded
   @OneToMany(mappedBy="b", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
   private List<C> cs;
}

@Entity
class C{
   @ContainedIn
   @ManyToOne(fetch=FetchType.LAZY)
   private B b;

   @IndexedEmbedded
   @ManyToOne(fetch=FetchType.LAZY)
   private D d;
}

@Entity
class D{
   @ContainedIn
   @OneToMany(mappedBy="d", fetch=FetchType.LAZY)
   private List<C> cs;

   @IndexedEmbedded
   @ManyToOne
   private E e;
}

@Entity
class E{
   @ContainedIn
   @OneToMany(mappedBy="e", fetch=FetchType.LAZY)
   private List<D> ds;

   @Field(index=Index.TOKENIZED, store=Store.NO)
   private String name;
}



All entities have their's own @Id anotated fields.

I'm searching by following field of A : "bs.cs.d.e.name".

When initial index is created I can successfully search by this field. But when I'm making some changes index is not updated.

Mostly I need index to be updated when I'm adding new "C" object to collection of "cs" of object "B". Also index is not updated when I'm removing some object "C" from collection of "cs" of object "B".

Please, let me know if such scenario is correct and how can it be fixed if not.
Thanks.


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Fri Jun 03, 2011 9:35 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Please, let me know if such scenario is correct and how can it be fixed if not.

Yes, that should work as you expect. Could you make a test for it for me to have a closer look? We have similar tests, but they don't fail so I need yours ;)

I assume this is version 3.4.0.Final ? Could you try it with 3.3.0.Final ? We did some crazy optimizations in the graph handling in the last release, I hope I didn't break something.

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


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 6:30 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Hi, s.grinovero

thank you for reply.

I'm using indeed version 3.4.0 Final.

I'm just tried version 3.3.0 Final and still no luck, index is not updated. Previously I used v 3.2.1 Final and it didn't update even second level of embedding(b.name). I've tried latest version 3.4.0 and it works now for second level. For fifth level it still doesn't work.

Could you please let me know what tests are you talking about? Do you mean sample complete source code (project) where this scenario doesn't work?


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 7:03 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Could you please let me know what tests are you talking about? Do you mean sample complete source code (project) where this scenario doesn't work?

I'm talking about the unit and functional tests we have in the project's source code, which you can clone from
https://github.com/hibernate/hibernate-search

Quote:
I'm just tried version 3.3.0 Final and still no luck, index is not updated. Previously I used v 3.2.1 Final and it didn't update even second level of embedding(b.name). I've tried latest version 3.4.0 and it works now for second level. For fifth level it still doesn't work.

That's unexpected, could you contribute a testcase, so I'll be able to have a look and either point out what's wrong with your code or fix the issue in Search.

Here is the project's issue tracker, please open a new issue and attach your testcase, or push it somewhere to github and then describe/link to it on JIRA:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH

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


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 9:15 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Well, it might be complicated...I'll try to do something....

Could it be the problem that I'm using hibernate 3.5.3 instead of latest? At least I cannot add tests from your source code to my project...


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 9:45 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Could it be the problem that I'm using hibernate 3.5.3 instead of latest?

Ah, yes that's a problem. Search often makes use of the last version of core released before the Search tag: it might happen we make some change in core to accomodate a need in Search, and that happened before 3.4 exactly for the collection updates.

Please update to core 3.6.4.Final.

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


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 10:23 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
If I could....I'm using JBoss 6.0.0.M5 and my customer doesn't have currently plans migrating to other versions....
So I'm keeping hibernate 3.5.3 (or 3.5.5 don't remember exactly) in order to not have problems with deployments to JBoss.

Well, thank you. Need to find some workaround...

P.S. Actually I tried just now to run under jetty with hibernate-core-3.6.3 and still no luck.... :(

Well, I definitelly should make test case for my scenario.
Hope soon will post my results....


Last edited by akucher on Mon Jun 06, 2011 10:34 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 10:34 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
JBoss 6.0.0.M5

So not only did he settle on an unsupported (community) version, but he choose a preview snapshot??
If you could get him to upgrade to JBoss 6 Final, you would find that it's using Hibernate core 3.6.3 in it, and you could replace it with 3.6.4 as it's a API compatible version, drop-in bugfix replacement only.

If you can not, you might want to checkout Hibernate Search's code, change the version to core 3.5.x and fix the compile errors, it should be trivial as most where additions of new methods defined in Session which need to be passed-through in Search (so you can delete them).
The main point is in org.hibernate.search.event.FullTextIndexEventListener : it's optimizing dirty checking for collection updates, you can compare the code with a 3.2 version of Hibernate Search and fix it by removing the optimizations.

It's open source ;)

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


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 10:38 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Ok, thank you for suggestions :)

I think it would be better for me to avoid 5 level depth of index :) and create some other search query for my functionality.

And it works ok as for me hibernate search 3.4 + hibernate 3.5 even without recompilation.


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 10:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
And it works ok as for me hibernate search 3.4 + hibernate 3.5 even without recompilation.

Yes, just be careful some methods on FullTextSession where added to delegate to the Session implementations, but some of these don't exist on Session in 3.5. Just make sure you use the FullTextSession interface only for full text, and avoid using other methods which are not defined on (your version of) Session as well.

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


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Mon Jun 06, 2011 11:04 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Honestly I'm using JPA so I'm using FullTextEntityManager.createFullTextQuery. I'm very new to hibernate search now, but I'll take into account that extended features of HiSearch requires newest hibernate.
Thanks again.


Top
 Profile  
 
 Post subject: Re: Depth of index update on @IndexedEmbedded
PostPosted: Wed Jun 15, 2011 5:47 am 
Newbie

Joined: Fri Jun 03, 2011 3:50 am
Posts: 14
Location: Ukraine
Well, I resolved where problem was. Some of the entities where marked as insertable=false, updatable=false, thats why parent index was not updated.

I didn't show the whole entity. Below are corrections.

Code:
....

@Entity
class B{

   @Column(name="PROJECT_ID", precision=10)
   private Long aId;

   @ContainedIn
   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumn(name="PROJECT_ID", insertable=false, updatable=false)
   private A a;

   @IndexedEmbedded
   @OneToMany(mappedBy="b", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
   private List<C> cs;
}

@Entity
class C{

   @Column(name="TEST_REQUEST_ID", precision=10)
   private Long bId;

   @ContainedIn
   @JoinColumn(name="TEST_REQUEST_ID"), insertable=false, updatable=false)
   @ManyToOne(fetch=FetchType.LAZY)
   private B b;

   @IndexedEmbedded
   @ManyToOne(fetch=FetchType.LAZY)
   private D d;
}

...


Soonce hibernate add some C entity in this was neither B or A indexes where updated. I did it in order to reduce number of queries to DB when save new entity but in case of lucene such approach should be forbidden.

I hope my case helps somebody to avoid such situation.

P.S. Well, I've been too fast.
It works good only while inserting new C - it updates B and A. But when I update C, it updates only B, and A remains not updated, even when I removed insertable=false, updatable=false. Also when C is deleted, B is updated but A is not.
Seems like it updates only first level of parent.

Any ideas?


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.