mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
OneToOne inserts with idType=SEQUENCE will fail #1480
This commit is contained in:
@@ -3,8 +3,8 @@ package org.tests.model.onetoone;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
@Entity
|
||||
public class OtoBChild {
|
||||
@@ -16,7 +16,7 @@ public class OtoBChild {
|
||||
String child;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "master_id", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn
|
||||
OtoBMaster master;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@@ -46,8 +46,8 @@ public class TestOneToOneImportedPkNative extends BaseTestCase {
|
||||
|
||||
List<String> lazyLoadSql = LoggedSqlCollector.stop();
|
||||
assertThat(lazyLoadSql).hasSize(2);
|
||||
assertThat(lazyLoadSql.get(0)).contains("select t0.id, t0.name, t1.master_id from oto_bmaster t0 left join oto_bchild t1");
|
||||
assertThat(lazyLoadSql.get(1)).contains("select t0.master_id, t0.child, t0.master_id from oto_bchild t0 where t0.master_id");
|
||||
assertThat(lazyLoadSql.get(0)).contains("select t0.id, t0.name, t0.id from oto_bmaster t0 where t0.id = ?");
|
||||
assertThat(lazyLoadSql.get(1)).contains("select t0.master_id, t0.child, t0.master_id from oto_bchild t0 where t0.master_id = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,12 +64,10 @@ public class TestOneToOneImportedPkNative extends BaseTestCase {
|
||||
|
||||
assertThat(m.getId()).isEqualTo(one.getId());
|
||||
assertThat(m.getName()).isEqualTo(one.getName());
|
||||
assertThat(m.getChild()).isNull();
|
||||
|
||||
OtoBMaster m2 = server.find(OtoBMaster.class, one.getId());
|
||||
assertThat(m2.getId()).isEqualTo(one.getId());
|
||||
assertThat(m2.getName()).isEqualTo(one.getName());
|
||||
assertThat(m2.getChild()).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user