I'm new to Spring MVC and Spring Roo.
What is field enum?
How can I enumerate all allowed values?
Is it implemented using lookup table or check constraint?
Roo's field enum --fieldName --type
command adds a private field of the specified enum type.
You can create the enum type by hand or use roo commands:
roo> enum type --class ~.domain.Colors
roo> enum constant --name BLAU
roo> enum constant --name VERMELL
This creates a Colors enum:
public Enum Colors {
BLAU, VERMELL
}
Then you can use then enum type to define an entity field:
roo> entity --class ~.domain.Foo
roo> field enum --fieldName color --type ~.domain.Colors
This will define the Foo entity:
//Annotations and imports ommited for brevity
public class Foo{
private Colors color;
}
See http://static.springsource.org/spring-roo/reference/html/command-index.html for a complete reference of the roo commands.
If you are going to use GWT or something similar you probably want to place the Colors class inside the shared package because enum classes are used by both the client and the server.
So you will do: enum type --class ~.shared.Colors
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