7

I am going through the hibernate 5.2.11.Final Documentation. the link http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#basic-lob. I noticed that the example of entity classes in the document is having the static modifier like

@Entity(name = "Product")
public static class Product {

    @Id
    private Integer id;

    private String name;

    @Lob
    private String warranty;

    //Getters and setters are omitted for brevity

}

As per my understanding a An Entity should be a top level class. In java a Top level class can not be static. So my question is how is it possible ? There are so many examples of entity in that documentation with the class as static so i don't think it is some unintentional mistake.

mnspati
  • 101
  • 1
  • 4
  • 2
    All top-level classes are, by definition, static. Therefore having the static keyword in a top-level class definition is pointless. Java compiler prohibits it. Why in the Hibernate 5.3 docs so many static class examples? No idea, maybe they used some code-generation tool and never worried to edit it. In the same doc v. 4.2 you will not see it at all. http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html_single/#example.collection.mapping.annotations – Andreas Gelever Jun 08 '18 at 10:46
  • 1
    "*All top-level classes are, by definition, static*" - seriously? – Giorgi Tsiklauri Mar 12 '21 at 20:52

1 Answers1

0

Static classes in documentation could be part of some enclosing class.

Peter Šály
  • 2,848
  • 2
  • 12
  • 26