-->
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.  [ 3 posts ] 
Author Message
 Post subject: @IndexedEmbedded and child id
PostPosted: Thu Jun 02, 2011 10:42 pm 
Newbie

Joined: Wed Mar 30, 2011 10:22 pm
Posts: 10
Hello everybody!
I have simple one to many relationship:

@Entity
class Parent {
@Id
@GeneratedValue
int id;

@OneToMany
@IndexedEmbedded
Set<Child> children;
String name;
}

@Entity
class Child{
@Id
@GeneratedValue
int id;
String name;
}

I can create index, everything looks good. But I just realized that Child.Id is stored in Parent document.
The number of children could be big, so my document is getting big also. I just want to index Parent by Child name, I don't want to waste space for Child ids. I don't need them. So, I have two questions
1. Why Child id is stored in Parent document?
2. Is there a way to remove Child id from Parent document?

Thank you,
Andrey


Top
 Profile  
 
 Post subject: Re: @IndexedEmbedded and child id
PostPosted: Fri Jun 03, 2011 8:39 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
1. Why Child id is stored in Parent document?

There are several reasons, but I'm not sure about if they are still all applying to latest versions; I'll raise the issue on the developer mailing list. Feel free to join ;)
http://www.hibernate.org/community/mailinglists

Quote:
2. Is there a way to remove Child id from Parent document?

There's no option to control that with the current implementation of @IndexedEmbedded, you could of course use a custom fieldbridge instead of that and then add all of child's names. Simple workaround, but viable only if you don't have many fields to add as it would quickly become complex code (you have only "name" right?).

Is this really significant, what's the impact on your index size?

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


Top
 Profile  
 
 Post subject: Re: @IndexedEmbedded and child id
PostPosted: Fri Jun 03, 2011 11:44 am 
Newbie

Joined: Wed Mar 30, 2011 10:22 pm
Posts: 10
Quote:
Quote:
2. Is there a way to remove Child id from Parent document?

There's no option to control that with the current implementation of @IndexedEmbedded, you could of course use a custom fieldbridge instead of that and then add all of child's names. Simple workaround, but viable only if you don't have many fields to add as it would quickly become complex code (you have only "name" right?).

Is this really significant, what's the impact on your index size?


Thank you very much. Things are actually worse then I described. My data is highly normalized and I have to get the "name" field from a grandchild. Which means I have two useless ids per object. Total could be up to several hundred. I will look into FieldBridge, it seems to be what I need.
Thank you,
Andrey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.