-->
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: improvement for @IndexedEmbedded fields
PostPosted: Mon Oct 01, 2007 6:09 pm 
Newbie

Joined: Mon Oct 01, 2007 6:56 am
Posts: 6
Hi there,

I've got a little improvement for the @IndexedEmbedded annotation in hibernate-search: right now, if the annotated field type is an interface, the @IndexedEmbedded annotation will have no effect on generated lucene indexes, since the referenced type will most likely be unmapped:

Code:
public inerface Parent
{
    public Set<Child> getChildren();
    public void setChildren(Set<Child> children);
}

public interface Child
{
    public Parent getParent();
    public void setParent(Parent parent);
}

...
@Entity
@Indexed
class ParentImpl
implements Parent
{
    @OneToMany(mappedBy = "parent")
    @ContainedIn
    private Set<Child> children;
    // getters/setters
}

@Entity
@Indexed
public class ChildImpl
implements Child
{
    @ManyToOne(targetEntity=ParentImpl.class)
    @JoinColumn(...)
    @IndexedEmbedded(prefix="parent_")
    private Parent parent;
}


Now there is the targetEntity parameter for most @*To* annotations and @org.hibernate.annotations.Target, if none of the former can be used.
Adding the same functionality to hibernate-search annotations is quite easy :
1) Create an IndexedTarget annotation
Code:
package org.hibernate.search.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Documented;

@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.FIELD, ElementType.METHOD } )
@Documented
/**
* Specifies the type of an association (@*ToOne or @Embedded)
*/
public @interface IndexedTarget {

    Class value();
}


2) Patch DocumentBuilder to read the new annotation data (patch against current trunk is available upon request)

Thoughts? Should I submit a JIRA issue?

Cheers,
jenner


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 02, 2007 12:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That makes sense.
Open a JIRA issue (and if possible attach the patch :) )

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 11:56 pm 
Newbie

Joined: Mon Oct 01, 2007 6:56 am
Posts: 6
emmanuel wrote:
That makes sense.
Open a JIRA issue (and if possible attach the patch :) )


Done: http://opensource.atlassian.com/project ... SEARCH-125

Cheers,
jenner


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.