Skip to content

Instantly share code, notes, and snippets.

@oranheim
Created March 3, 2015 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oranheim/e21063f0a0002be95df0 to your computer and use it in GitHub Desktop.
Save oranheim/e21063f0a0002be95df0 to your computer and use it in GitHub Desktop.
// User model
@Exclude
@XmlRootElement(name = "user")
@XmlAccessorType(XmlAccessType.PROPERTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class User extends Principal {
@Column(name = "USERNAME", nullable = false, length = 20)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "FIRSTNAME", length = 50, nullable = false)
@NotNull
@Size(min = 3, max = 50)
public String getFirstname() {
return firstName;
}
public void setFirstname(String firstName) {
this.firstName = firstName;
}
@Column(name = "LASTNAME", length = 50, nullable = false)
public String getLastname() {
return lastName;
}
public void setLastname(String lastName) {
this.lastName = lastName;
}
/*
If this getter is uncommented FasterXml Jackson throws
org.jboss.resteasy.spi.ReaderException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "user" Unrecognized field "user" (class com.parts.commons.model.user.User)
@Transient
@JsonIgnore
@JsonProperty("fullName")
public String getFullName() {
return firstName + ' ' + lastName;
}
*/
// ... associations...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment