0

I am using scala, hibernate with postgress database

how to auto increment the id which is primary key and serial in postgress data base

here is my model

@Entity
@Table(name = "event_user")
class User( id: Option[Long] = None, email1: String, password: String, first_name1: String, last_name1: String) {

  @Id
  var id: Long = _

  @Column(name = "email")
  var email : String = email1

  @Column(name = "password")
  var passWord : String = password

  @Column(name = "first_name")
  var first_name : String = first_name1

  @Column(name = "last_name")
  var last_name : String = last_name1

  def this() = this (None, null, null, null, null)

}
Marth
  • 23,920
  • 3
  • 60
  • 72

1 Answers1

0

You have to tell JPA that id should be autogenerated by using @GeneratedValue annotation. You can find an example here

Community
  • 1
  • 1
Arek
  • 3,106
  • 3
  • 23
  • 32