[
https://hibernate.onjira.com/browse/HSEARCH-1108?page=com.atlassian.jira....
]
Manthos commented on HSEARCH-1108:
----------------------------------
As far as I remember, programmatic API creates Annotations (with AnnotationFactory) and
works like you annotate your Entities in your source.
ex:
{code}
@MappedSuperclass
public class Foo {
@Basic
public String foo;
}
@Entity
public class Bar extends Foo {
@Basic
public String bar;
}
{code}
So you have to...
{code}
searchMapping.entity(Foo.class)
.property("foo", ElementType.FIELD).field();
searchMapping.entity(Bar.class).indexed();
.property("bar", ElementType.FIELD).field();
{code}
As far as I know, per Entity Mapping is currently not possible. So if you have another
Entity, ex 'Baz extends Foo', Baz inherits Foo mappings. The same for Embeddable
classes.
It would be a nice if programmatic API could manage inherited properties (from
MapperSuperclass and Embeddable) per Entity... but I'm afraid that this is a big
change...
Please feel free to clarify if I'm wrong.
programmatic API doesn't work correctly for entities with
@MappedSuperclass parent
----------------------------------------------------------------------------------
Key: HSEARCH-1108
URL:
https://hibernate.onjira.com/browse/HSEARCH-1108
Project: Hibernate Search
Issue Type: Bug
Components: mapping
Affects Versions: 4.0.0.Final, 4.1.0.Final
Environment: HibernateCore 4.1.2, HSearch 4.1.0, Glassfish3 (JPA) or even as a
standalone java app
Reporter: David Janca
Labels: candidate_for_next, programmatic
The hibernate search configuration specified by programmatic API (SearchMapping class) is
ignored for entities that have @MappedSuperclass parent.
All fields that are declared in a @MappedSuperclass parent are not recognized by
programmatic config and ignored (when configured like this:
mapping.property("property", ElementType.FIELD)).
We've already found a workaround for this problem - to overwrite getter method in
@Entity class (just calling super.getter) and configure it like following:
mapping.property("property", ElementType.METHOD). But I think that's not the
real solution.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira