I think this bug can be closed, because we don't have such thing as a fieldNameToPositionMap anymore. We simply ask Hibernate ORM to retrieve values for us. The test case still doesn't work, but think it's more of an usage issue. In the test case, the @Id annotation is added on the id field, and not on the id getter. This means that Hibernate will use the "field" access type for the whole class, and will never use getters unless instructer otherwise. Thus when you annotate the getText method with @Field, you are annotating a random method that has no significance to Hibernate whatsoever. In order to get the test to work, there are several options:
- If this exotic field naming it's a one-time thing, you can add @javax.persistence.Access(javax.persistence.AccessType.PROPERTY) on the getText method and @javax.persistence.Transient on the field. This way, Hibernate will ignore the field and will only use getText/setText.
- If you expect to name all of your properties this way, you have two solutions:
- Either you want to use property access (access through getters/setters), in which case you have to move all of your annotations to getters (especially the @Id), including Hibernate Search annotations
- or you want to use field access, in which case you have to move all of your annotations to fields (especially the @Field that has to be on _test instead of getText)
I added some commits [on this repo](https://github.com/yrodiere/hibernate-test-case-templates/commits/HSEARCH-1078) to demonstrate the various solutions (see the last four commits). Of course the fact that Search annotations must be added in a different place depending on the access type may seem weird, but we already have a ticket about that:
HSEARCH-383 Open Elmer van Chastelet Do these solutions make sense? Can we close this issue? Thanks. |