mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1785 - Bean gets replaced on json deserialization with primitive 'null' id
This commit is contained in:
@@ -10,7 +10,7 @@ import javax.persistence.Version;
|
||||
public class RelMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
long id;
|
||||
|
||||
String name;
|
||||
|
||||
@@ -20,11 +20,11 @@ public class RelMaster {
|
||||
@ManyToOne(cascade = CascadeType.REMOVE)
|
||||
private RelDetail detail;
|
||||
|
||||
public Long getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.tests.cascade;
|
||||
|
||||
import io.ebean.DB;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestJsonMarshallingOTM {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
String json = ("" +
|
||||
"{ 'masterRel': [" +
|
||||
" { 'name': 'a' }," +
|
||||
" { 'name': 'b' }" +
|
||||
"] }"
|
||||
).replaceAll("'", "\"");
|
||||
|
||||
RelDetail bean = DB.json().toBean(RelDetail.class, json);
|
||||
|
||||
final RelMaster m0 = bean.getMasterRel().get(0);
|
||||
assertThat(m0.getName()).isEqualTo("a");
|
||||
final RelMaster m1 = bean.getMasterRel().get(1);
|
||||
assertThat(m1.getName()).isEqualTo("b");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user