Contents contributed and discussions participated by kuni katsuya
Contents of API Design with Java - 0 views
Spring Security Demo - HD - YouTube - 0 views
Java EE Security Demo - HD - YouTube - 0 views
Apache Shiro Demo - HD - YouTube - 0 views
JPA and Enums via @Enumerated - 0 views
3 ways to serialize Java Enums | Vineet Manohar's blog - 0 views
-
Mapping enum to database column using JPA/Hibernate You can use any of the 3 approaches discussed above. Map the enum to an integer column. The persistence implementation should automatically convert enum to ordinal() and back for you. Map the enum to a String column. The persistence implementation should automatically convert the enum value to String value via the name() function. Map the enum using a business value. You should mark the enum field as @Transient, and create another String field which you can map to a String column in your database table. Here’s an example code snippet. view plaincopy to clipboardprint?@Entity public class Product { @Column private String colorValue; @Transient public Color getColor() { return Color.fromValue(colorValue); } public void setColor(Color color) { this.colorValue = color.toValue(); } }
-
Approach 3: Using a user defined business value – Recommended approach! This approach involves assigning a an explicit user defined value to each enum constant and defining a toValue() and fromValue() methods on the enum to do the serialization and deserialization.
-
public enum Color { RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN"); private final String value; Color(String value) { this.value = value; } public static Color fromValue(String value) { if (value != null) { for (Color color : values()) { if (color.value.equals(value)) { return color; } } } // you may return a default value return getDefault(); // or throw an exception // throw new IllegalArgumentException("Invalid color: " + value); } public String toValue() { return value; } public static Color getDefault() { return UNKNOWN; } } public enum Color { RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN"); private final String value; Color(String value) { this.value = value; } public static Color fromValue(String value) { if (value != null) { for (Color color : values()) { if (color.value.equals(value)) { return color; } } } // you may return a default value return getDefault(); // or throw an exception // throw new IllegalArgumentException("Invalid color: " + value); } public String toValue() { return value; } public static Color getDefault() { return UNKNOWN; } } This approach is better than approach 1 and approach 2 above. It neither depends on the order in which the enum constants are declared nor on the constant names.
Chapter 5. AS3 Code Generator - 0 views
-
5.2. Generated ActionScript 3 Classes
-
Gas3 uses the principle of "Base" and customizable inherited classes that let you add methods to generated classes without facing the risk of losing them when a new generation process is executed
-
5.3. Java Classes and Corresponding Templates
- ...13 more annotations...
Introduction to Robustness Diagrams - 0 views
-
Boundary
-
Control
-
Entity
- ...7 more annotations...
« First
‹ Previous
801 - 820 of 1268
Next ›
Last »
Showing 20▼ items per page