@Test public void manyToOne_setAccount() { Document many = new Document(); // init Account one = new Account(); one.setId(ValueGenerator.getUniqueString(32)); many.setAccount(one); // make sure it is propagated properly assertNotNull(many.getAccountId()); assertEquals(one, many.getAccount()); assertSame(many.getAccountId(), one.getId()); // now set it to back to null many.setAccount(null); // make sure null is propagated properly assertNull(many.getAccount()); // make sure it is propagated on fk column as well assertNull(many.getAccountId()); }