mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1739 - Entity with just @Id and @OneToMany fields produces broken insert query
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package org.tests.insert;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class OnlyIdEntity {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.insert;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestOnlyIdEntity {
|
||||
|
||||
@ForPlatform({Platform.H2, Platform.POSTGRES})
|
||||
@Test
|
||||
public void insert() {
|
||||
|
||||
final Database database = DB.getDefault();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
OnlyIdEntity bean = new OnlyIdEntity();
|
||||
database.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
assertThat(bean.getId()).isGreaterThan(0);
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("insert into only_id_entity default values");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user