Creating table automatically using Hibernate


#1

I tried GenerationType.IDENTITY to my Entity class. it looks ike this

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private int id;

and added

property name="hibernate.hbm2ddl.auto " as “update”

to hibernate.cfg file. But it didn’t created the Entity to schema automatically.
When i used

GenerationType.AUTO

it works fine. I am new in hibernate. Any explanation ?


#2

You need to paste the stack trace to see what happens. You say it does not work, but let’s see that in the output.