Bug 1033231

Summary: Usage of Hibernate specific annotations in domain model examples
Product: [JBoss] JBoss Data Grid 6 Reporter: Sanne Grinovero <sanne>
Component: DocumentationAssignee: Misha H. Ali <mhusnain>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: high    
Version: 6.2.0CC: anistor, jdg-bugs, sanne
Target Milestone: GA   
Target Release: 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Build Name: 14318, Infinispan Query Guide-6.2-1 Build Date: 21-11-2013 08:29:28 Topic ID: 14251-507055 [Latest]
Last Closed: 2014-01-16 00:03:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sanne Grinovero 2013-11-21 18:27:23 UTC
This applies to all examples, but I first found the problem in Example 2.5 Using @AnalyzerDef and the Solr Framework to Define and Use an Analyzer


Describe the issue:
The example domain objects should never have any of these annotations:
- @Entity
- @GeneratedValue
- @DocumentId
- @Id
- @ManyToMany
- @ManyToOne
- @OneToMany

Also:
= the attributes usually annotated via @Id or @DocumentId need to be completely removed (not just the annotation).
= all example domain objects must implement Serializable

Suggestions for improvement:
For example the code for example 2.5 should be:

@Indexed
@AnalyzerDef(
   name = "customanalyzer",
   tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
   filters = {
      @TokenFilterDef(factory = LowerCaseFilterFactory.class), 
      @TokenFilterDef(factory = SnowballPorterFilterFactory.class,
         params = { @Parameter(name = "language", value = "English") })
 })
public class Book implements Serializable {

  @Field
  @Analyzer(definition = "customanalyzer")
  private String title;
  
  @Field
  @Analyzer(definition = "customanalyzer")
  private String subtitle; 

  @IndexedEmbedded
  private Set authors = new HashSet();

  @Field(index = Index.YES, analyze = Analyze.NO, store = Store.YES)
  @DateBridge(resolution = Resolution.DAY)
  private Date publicationDate;
  
  public Book() {
  } 
  
  // standard getters/setters follow here
  ... 
}

Finally, please take particular care with necessary vertical alignment in code. I realize it's not usually fundamental in text, but developers are particularly sensitive to finding it very disturbing.

Comment 2 Misha H. Ali 2013-11-22 01:51:00 UTC
WIP

Comment 4 Adrian Nistor 2013-11-26 20:41:59 UTC
The particular code snippet mentioned by Sanne is now fixed as he suggested, but there are several others that need the same treatment regarding the use of @Id and @DocumentId annotations (which are meaningless in the Infinispan Query context and should be removed). How can I help? I can convert the other code snippets, but not sure it's wise to open another dozen of bugzillas for them. Can I do the corrections somehow directly in the document?

Comment 5 Adrian Nistor 2013-11-26 20:52:30 UTC
Directly related to this issue: there is a section "4.1.1.4. @Id" which should be removed. Instead we should add a section stating that @Id, @DocumentId, @Entity, etc (mentioned earlier by Sanne) are not useable in the context of JDG
Query. A similar section exists in Infinispan Query user guide: http://infinispan.org/docs/6.0.x/user_guide/user_guide.html#_notable_differences_with_hibernate_search

Comment 6 Adrian Nistor 2013-11-26 22:04:45 UTC
Please ignore my comment #4 and #5, it seems I somehow switched to the Hibernate Search guide, not the 'Infinispan Query Guide'. Too many browser tabs open.

So yes, this is fixed and can be closed.

Comment 7 Misha H. Ali 2013-11-26 23:30:46 UTC
Thanks very much, Adrian!

Comment 8 Misha H. Ali 2014-01-16 00:03:04 UTC
The fix for this bug is now generally released and available here:

https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.2/index.html