Feuler
Feuler

Reputation: 11

How to create a key by JPA annotation (not primary key, just key)

If there is a table creating statement like

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(64) NOT NULL,
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

What annotation should I use to implement KEY `username` (`username`)?
I've try looking up annotations in javax.persistence but no result.

Upvotes: 0

Views: 69

Answers (1)

Feuler
Feuler

Reputation: 11

Fine, I solved this question by myself with using

columnDefinition = "VARCHAR(64) KEY"

Please let me know if anyone has a better idea.

Upvotes: 1

Related Questions