#2217 - Inserting an entity bean is skipped with a String @Id property and no other properties set

This commit is contained in:
rbygrave
2021-04-06 21:13:59 +12:00
parent 3e97a4005a
commit bb1275f4f9
6 changed files with 116 additions and 2 deletions
@@ -25,6 +25,10 @@ public class PersonCacheEmail {
this.email = email;
}
public PersonCacheEmail(String id) {
this.id = id;
}
public String getId() {
return id;
}
@@ -0,0 +1,73 @@
package org.tests.cache.personinfo;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.validation.constraints.Size;
import java.time.Instant;
@Entity
public class PersonOther {
@Id
@Size(max=128)
private String id;
private String email;
@WhenCreated
private Instant whenCreated;
@WhenModified
private Instant whenModified;
@Version
private long version;
public PersonOther(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Instant getWhenCreated() {
return whenCreated;
}
public void setWhenCreated(Instant whenCreated) {
this.whenCreated = whenCreated;
}
public Instant getWhenModified() {
return whenModified;
}
public void setWhenModified(Instant whenModified) {
this.whenModified = whenModified;
}
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
}
@@ -0,0 +1,30 @@
package org.tests.cache.personinfo;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class TestStringIdOnly extends BaseTestCase {
@Test
public void insert() {
PersonCacheEmail b0 = new PersonCacheEmail("IdOnly");
DB.save(b0);
PersonCacheEmail found = DB.find(PersonCacheEmail.class, b0.getId());
assertThat(found).isNotNull();
}
@Test
public void insert_whenIdOnly() {
PersonOther b0 = new PersonOther("IdOnly");
DB.save(b0);
PersonOther found = DB.find(PersonOther.class, b0.getId());
assertThat(found).isNotNull();
}
}