Reputation: 2804
I want Username = Administrator and Password = admin, soon after table is created (or whenever table is recreate).
Is there any constraint in Hibernate to restrict user from deleting (first) row
@Entity
@Table(name = "Users")
public class Users implements Serializable {
@Id
@Column(name = "Username", unique = true, nullable = false)
private String username;
@Column(name = "Password", nullable = false)
private String password;
/**************** getter & setter ************/
}
Upvotes: 0
Views: 757
Reputation: 5811
What you seem to be looking for is called fixtures. With Hibernate you can supply import.sql
file on your classpath with your initial data (insert statements).
There's a bit more information on the JBoss' site.
The import.sql
file is a simple text file with SQL statements, one line per statement:
insert into users (id, username) values (1, 'administrator');
insert into users (id, username) values (2, 'user');
...
Upvotes: 2