briefly, can someone tell me what an annotation is in hiberate? (java)
is it a way to quickly map entities to tables?
briefly, can someone tell me what an annotation is in hiberate? (java)
is it a way to quickly map entities to tables?
Yes, Hibernate annotations are used on domain classes, instead of using mapping files (hibernate.cfg.xml, etc.). I guess you can google about details. Briefly, it is a more convenient way to define your mappings and their attributes.
Its way more than that. In hibernate they are used to tell the tools that process your code the meaning of the parts of your code. So
@Entity
public class MyClass{}
will be processed (that is the code itself will be read) and the @Entity annotation indicates that the MyCLass class is an Entity - represents real world data.
A similar thing can be achieved with xml files but that would required managing multiple files.
So in a way it allows you to specify meta data about your code.
Basically your annotations are your analogous of the xml config that's all there is to it, so therefore the annotations equivalent of
<property name="description" column="descriptive_text" />
is
@Column(name="descriptive_text")
private String description;
Keep in mind that @Column
is the JPA standard (@javax.persistence.Column
) of which Hibernate is an implementation. There are, of course, Hibernate specific annotations like @org.hiberanate.annotations.Immutable
which specifies that an entity or collection are immutable. Further info here.