mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#529 - @OneToOne with @JoinColumn to non primary key throws Data conversion error
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.avaje.tests.model.onetoone;
|
||||
|
||||
import com.avaje.tests.model.basic.BasicDomain;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class OCompany extends BasicDomain {
|
||||
|
||||
@Column(length = 50, unique = true)
|
||||
public String corpId;
|
||||
|
||||
public String getCorpId() {
|
||||
return corpId;
|
||||
}
|
||||
|
||||
public void setCorpId(String corpId) {
|
||||
this.corpId = corpId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.avaje.tests.model.onetoone;
|
||||
|
||||
import com.avaje.tests.model.basic.BasicDomain;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class ORoadShowMsg extends BasicDomain {
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, optional = false)
|
||||
@JoinColumn()//(name = "corp_id", nullable = false, referencedColumnName = "corp_id")
|
||||
public OCompany company;
|
||||
|
||||
public OCompany getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(OCompany company) {
|
||||
this.company = company;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.avaje.tests.model.onetoone;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestOneToOneJoinColumn extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
ORoadShowMsg msg = new ORoadShowMsg();
|
||||
OCompany company = new OCompany();
|
||||
company.setCorpId("corp_id_1000000");
|
||||
msg.setCompany(company);
|
||||
|
||||
Ebean.save(msg);
|
||||
Ebean.find(ORoadShowMsg.class, msg.getId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user