I guess I see a shared PK as no less
normal than a unique FK in such a case. ;-)
But say I could get SecondaryTable to work (more on that in a moment) wouldn't that automatically set a shared PK on the second table? In other words, wouldn't the behavior I asked about that does not exist with OneToOne, work in the context of SecondaryTable?
After my initial post, I tried to reimplement with SecondaryTable:
@Entity
@Table(name = "users")
@SecondaryTable(name = "user_settings")
public class User extends Model
{
@Id
@Column(name = "user_id")
public Long id;
@Column(unique = true)
public String username;
@Column(table="user_settings")
private String timeZone;
// [...other stuff...]
}
But I get this stack trace, even though both the users and user_settings table exist each with a user_id column (auto-inc on users):
[error] c.a.e.s.d.BeanDescriptorManager - Error in deployment
java.lang.NullPointerException: null
at com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor.findJoinToTable(DeployBeanDescriptor.java:899) ~[avaje-ebeanorm-server.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.secondaryPropsJoins(BeanDescriptorManager.java:658) ~[avaje-ebeanorm-server.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityRelationships(BeanDescriptorManager.java:628) ~[avaje-ebeanorm-server.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:256) ~[avaje-ebeanorm-server.jar:na]
[snip]
Have I left out some necessary config?
-GBS