• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is @Basic annotation ?  RSS feed

 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that @Basic annotation (of Hibernate ORM) on a java variable only declares that the variable must be saved as a column with NOT NULL constraint. Is that correct ?

A post on stackoverflow says that it is not so -


@Basic(optional = false) @Column(nullable = false) The @Basic annotation marks the property as not optional on the Java object level. The second setting, nullable = false on the column mapping, is only responsible for the generation of a NOT NULL database constraint. The Hibernate JPA implementation treats both options the same way in any case, so you may as well use only one of the annotations for this purpose.


I am confused.
 
Paul Clapham
Sheriff
Posts: 22722
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see it in the standard Java API anywhere. So it would help if you mentioned where this annotation came from. What package it's in, what product it's associated with, something to provide background.
 
Ron McLeod
Bartender
Posts: 1602
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it this: Annotation Type Basic?
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I don't see it in the standard Java API anywhere. So it would help if you mentioned where this annotation came from. What package it's in, what product it's associated with, something to provide background.

Hibernate. If there is a @Basic. Then is there an @Advanced too ?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37403
531
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali,
No, there isn't @Advanced. There are more specific advanced annotations though like @Temporal. With @Temporal, you specify whether you want to store the value as a date, time or date/time.

You can see the full list of annotations in the annotations section of javax.persistence if you are curious.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!