質問

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