I have an entity called StockLevel
and another one called Version
and they are in a relationship like this:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "version", nullable = false, referencedColumnName = "pk")
private VersionModel version;
Now I want to create a new StockLevel
via Spring-Data-REST so I issue the following POST request to http://somedomain.com:8111/storefront/rest/stock_level/
{
"uid" : "mynewuidForStockLevel",
"version" :
{
"rel" : "version",
"href":"http://localhost:8111/storefront/rest/version/3378719354003680"
}
}
Here is my Version
model:
@Cacheable
@Entity(name = VersionModel.NAME)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = VersionModel.NAME,
uniqueConstraints = { @UniqueConstraint(columnNames = { "pk" }) },
indexes = { @Index(columnList = "id")})
public class VersionModel extends AbstractEntityModel {
public static final String NAME = "version";
}
however I get a Null-pointer exception in Fasterxml Jackson:
Caused by: java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3023)
at java.net.URI.<init>(URI.java:595)
at java.net.URI.create(URI.java:857)
at org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$UriStringDeserializer.deserialize(PersistentEntityJackson2Module.java:359)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:525)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:99)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242)
What am I doing wrong?