-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping an unidirectional relationship
PostPosted: Wed Apr 23, 2008 9:38 am 
Beginner
Beginner

Joined: Wed Feb 27, 2008 12:34 pm
Posts: 21
Hi!

I've got a class named Ficha whith a set of objects of another class named Materia. Like this:

@Indexed
public class Ficha {
.......
@Id
@DocumentId
protected Long idFicha;

@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
@JoinTable(name = "rel_materia_ficha_tarifa", joinColumns = { @JoinColumn(name = "ficha_tarifa_id") }, inverseJoinColumns = { @JoinColumn(name = "materia_id") })
@IndexedEmbedded
protected Set<Materia> materias = new HashSet<Materia>();

......
}


@Entity
@Indexed
public class Materia{

......
@Id
@DocumentId
private String codigo;


@Field(index = Index.TOKENIZED, store = Store.NO)
@Boost(2.0f)
private String descripcion;

.......
}

I'm working with queries about Ficha class, I mean, I want to retrieve lists of Ficha objects. However, I don't know how I can set the Lucene indexes aware of any change in the Materias objects. I mean, I'd like to do the same that the annotation @ContainedIn does in a bidirectional relationship .

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 10:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

to let Hibernate Search automatically handle this you would have to make your relation bidirectional and use @ContainedIn.

If for some reason you cannot use a bidirectional relationship you could try catch changes to Materia instances via event listeners, run a Hibernate query to find all Ficha instances having a reference to your Materia instance and trigger a manul index update. I've never tried something like this before though ;-)

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.