Bug 1033231 - Usage of Hibernate specific annotations in domain model examples
Summary: Usage of Hibernate specific annotations in domain model examples
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Data Grid 6
Classification: JBoss
Component: Documentation
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: GA
: 6.2.0
Assignee: Misha H. Ali
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-21 18:27 UTC by Sanne Grinovero
Modified: 2014-01-16 00:03 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
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


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.