Hibernate Column

This tutorial explains the concept of column annotation in hibernate.

Ads

Tutorials   
Hibernate 5 configuration dtd Hibernate 5 Hello World Getting started with Hibernate 5 Hibernate 5.2.10 jar Download Hibernate 5.2.10 Maven Dependency Hibernate 5 Maven Dependency Hibernate 5 native query example Hibernate 5 query deprecated When should you use Hibernate? What's new in Hibernate 5? How much time it takes to learn Hibernate? Hibernate envers custom revinfo table Hibernate 5 Envers Hibernate Envers get all revisions Hibernate Examples Hibernate 5 build SessionFactory Example Hibernate 5 SessionFactory Example Hibernate 5 Annotation Example How to download Hibernate 5.x? Hibernate 5 Features Hibernate 5 Tutorials Learning Hibernate ORM - Free Training/Tutorial videos of Hibernate ORM with Java How to write hello world example program in Hibernate? How to create one to one relationship in Hibernate 4 with Annotation? How to calculate minimum in Hibernate using the min() Function Hibernate ORM 4.2.21.Final Released - Create CURD application in latest Hibernate Hibernate ORM 4.2.21 Tutorial - Learn Hibernate ORM Framework Hibernate Error: Failed to create sessionFactory object.java.lang.NoClassDefFoundError How to create Hibernate Project in Eclipse? Examples of Hibernate Criteria Query Hibernate ORM 4.3.6.Final released Hibernate ORM 4.2.14.Final released Hibernate 4.3.4 Released: Hibernate 4.3.4.Final Maven dependency Hibernate association and join example Learn Hibernate programming with Examples Introduction to Hibernate Framework Hibernate Tutorial: Learn Hibernate with examples Hibernate 4.3 Hello World: Example Hibernate ORM 4.3.1.Final released How to create SessionFactory in Hibernate 4.3.1?

Hibernate Column

This tutorial explains the concept of column annotation in hibernate.

Hibernate column :

In Hibernate, column attribute plays an important role in mapping table. column annotation is defined in javax.persistence package. It is used to define a mapped column for a persistence field.

As we map table fields in our persistence class by using @column annotation and also we can specify other properties.

Syntax -

@Column(name="column_name" ,columnDefinition="CLOB NOT NULL" ,insertable=true/false ,length=N ,nullable=true/false ,precision=N ,scale=N ,table="" ,unique=true/false ,updatable=true/false)

Description of Optional Elements:

name: It is name of column that represent to table field. by default it takes field name or property.
Default value: ""

columnDefinition: It shows the SQL fragment that is used when generating the DDL for the column. By default it takes the generated SQL to create a column of the inferred type.
Default value: ""

insertable: It is used to check for the column is included in SQL INSERT statements which is generated by the persistence provider or not.
Default value: true

nullable: It is of Boolean type and checks the column name is either nullable or not.
Default value: true

length: It is optional and sets the column length only if you use string valued column.
Default value : 255

precision: It is optional applies only if a decimal column is used. Value is set by programmer if used when generating the DDL for column.
Default value: 0

scale: It is used for scaling for a decimal(exact numeric) column and is applied only if a decimal column is presented.
Default value : 0

table: It refer to the name of the table that contains the column. If it is not present then the column name is assumed to be in the primary table.
Default value: ""

unique: It checks whether the property is a unique key or not. It is useful for checking unique key constraint of single field.
Default value: false

updatable: It checks whether the column updatable or not
Default value: true

Advertisements

Share on Google+Share on Google+

Hibernate Column

Posted on: July 4, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Hibernate Column  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads