문제

I have Registration table.That has many duplicate entries. Here duplicate entries in terms of same username. so I want to know how to prevent the duplicate entries in a table. I am using Hibernate and java servlet.

도움이 되었습니까?

해결책

You should create an unique constraint on the username.

@Entity
@Table(uniqueConstraints=
           @UniqueConstraint(columnNames = {"username"})) 
public class Registration {
    //...
}

다른 팁

@Column(name = "username",unique=true)

at column level.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top