I'm using ebean, it's very easy to use but I don't know create my custom index.
@Entity
@Table(name="users")
public class User {
public String name;
// how to create index for this column?
public long displayOrder;
}
I tried to create index for the column displayOrder, but how to do it?
There is no annotation for this, and the generated ddl file will be recreated each time, so I can't add my own ddl statements there. And it's not convenient to add index in database directly.
Is there any simple solution to do it?
There is no direct answer, but I think, that you should concern on it for a while.
AFAIK there's no way to declare 'KEY' index via annotations, you can only add @Column(unique=true) to it (if you need an unique field).
Of course for primary key you just need to use @Id annotation.
On the other hand I do not recommend using automatic DDL creation every time - remember, that will destroy all your DB structure and data after next evolution applying!!! Instead go with this way:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With