开发者_运维知识库I thought when I have a class that I add the @Entity to it and also map it to a table, then when on a get property I add the @Column attribute and tell it what column of that table it should map it to... then I saw the @Transient annotation and it says if we add @Transient to a get, then Hibernate will Not save it to DB...so then I got confused: so does it mean default behaviour of Hibernate is to map every get to a similar named column in DB?
Every non static non transient property (field or method depending on the access type) of an entity is considered persistent, unless you annotate it as @Transient. Not having an annotation for your property is equivalent to the appropriate @Basic annotation. The @Basic annotation allows you to declare the fetching strategy for a property:
@official hibernate documentation
See http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entity-mapping-entity.
Depending on where you put the @Id
annotation (on a field or on a getter), all fields or getters not marked with @Transient
will automatically be made persistent, with a default column name.
精彩评论