Tweaked how the version is exposed. It isn't by default so I added a check for @RestResource on the version attribute. If a path is set, the version is exported under that name.
This commit is contained in:
@@ -61,10 +61,15 @@ public class JpaEntityMetadata implements EntityMetadata<JpaAttributeMetadata> {
|
||||
if(repositories.hasRepositoryFor(attrType)) {
|
||||
linkedAttributes.put(name, new JpaAttributeMetadata(entityType, attr));
|
||||
} else {
|
||||
if(!(attr instanceof SingularAttribute && ((SingularAttribute)attr).isId())
|
||||
&& !(attr instanceof SingularAttribute && ((SingularAttribute)attr).isVersion())) {
|
||||
embeddedAttributes.put(name, new JpaAttributeMetadata(entityType, attr));
|
||||
if((attr instanceof SingularAttribute && ((SingularAttribute)attr).isId())) {
|
||||
// Don't export the id attribute
|
||||
continue;
|
||||
} else if(((attr instanceof SingularAttribute) && ((SingularAttribute)attr).isVersion())
|
||||
&& (null == fieldResourceAnno || !StringUtils.hasText(fieldResourceAnno.path()))) {
|
||||
// Don't export the version attribute
|
||||
continue;
|
||||
}
|
||||
embeddedAttributes.put(name, new JpaAttributeMetadata(entityType, attr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.persistence.PrePersist;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonManagedReference;
|
||||
import org.springframework.data.rest.repository.annotation.RestResource;
|
||||
|
||||
/**
|
||||
* @author Jon Brisbin <jbrisbin@vmware.com>
|
||||
@@ -23,6 +24,7 @@ public class Person {
|
||||
|
||||
@Id @GeneratedValue private Long id;
|
||||
private String name;
|
||||
@RestResource(path = "version")
|
||||
@Version
|
||||
private Long version;
|
||||
@JsonManagedReference
|
||||
|
||||
Reference in New Issue
Block a user