Skip to content

Instantly share code, notes, and snippets.

@Tcharl
Created November 11, 2014 17:35
Show Gist options
  • Select an option

  • Save Tcharl/db59c28832bb3c1f67f8 to your computer and use it in GitHub Desktop.

Select an option

Save Tcharl/db59c28832bb3c1f67f8 to your computer and use it in GitHub Desktop.
Simple entity
@Data
// equals, hashcode, getters and setters
@Builder
// builder pattern
@NoArgsConstructor
// constructor
@AllArgsConstructor
// other constructor
@Entity
// persistence class declaration
@XmlRootElement
// xml marshalling
@EqualsAndHashCode(callSuper = true)
@ApiModel( value = "Hello Entity", description = "Hello resource representation" )
public class HelloEntity extends AbstractEntity implements Serializable /* in order to be sendable via JMS*/{
/**
* Serial
*/
private static final transient long serialVersionUID = 6233801298404301547L;
/**
* Message
*/
@XmlElement
// XML node
@NotNull(message = "message must not be null")
// Validation for null object
@Size(min = 2, max = 12, message = "message size must be between 2 and 12")
// size validation
@Pattern(regexp = "[a-zA-Z0-9]+", message = "must not contain special characters")
// pattern validation
@ApiModelProperty( value = "The thing to greet", required = true )
private String helloMessage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment