Java – spring Roo, field enumeration
•
Java
I'm new to spring MVC and spring roo
What is field enumeration?
How do I enumerate all allowed values?
Is it implemented using lookup tables or check constraints?
Solution
Roo's field enumeration – fieldname – type command adds a private field of the specified enumeration type
You can create enumeration types manually or use the roo command:
roo> enum type --class ~.domain.Colors roo> enum constant --name BLAU roo> enum constant --name VERMELL
This creates a color enumeration:
public Enum Colors { BLAU,VERMELL }
You can then define entity fields using enumeration types:
roo> entity --class ~.domain.Foo roo> field enum --fieldName color --type ~.domain.Colors
This defines the foo entity:
//Annotations and imports ommited for brevity public class Foo{ private Colors color; }
For a complete reference to the roo command, see http://static.springsource.org/spring-roo/reference/html/command-index.html.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码