I'm in JPA trouble again. And again it's some relationship that isn't right. I only get on side of the relation updated upon "find". When I inspect the database the IDs seem to be in place.In TheTest below I first create a User and then a Category. They should be linked and the Category should know who has created it (which works, line 19), and the User should know which Categories (Items) it has created -- this doesn't work, line 20.Included are snippets of the two entities, their entity access beans, and some sql that creates the very tables at the bottom.In the CategoryEAOBean's factory method (which persists) I'm in doubt how to update the relation, line 140-142. This might be the root of the problem. But then again: relations seem allright in thepublic class TheTest{ ... @Test public void shouldCreateCategoryWithCreateUser () { User unmanagedUser = new User( "login", "password", ... ); User user0 = userEAO.create( unmanagedUser ); assertEquals( 0, user0.getCreatedItems().size() ); Category unmanagedCategory = new Category("simple-category-name", ..., user0, ... ); // Seting CreateUser Category category0 = categoryEAO.create( unmanagedCategory ); User user = userEAO.findById( user0.getId() ); // Refresh User since Category was added. assertEquals( user0.getId(), user.getId() ); assertEquals( unmanagedCategory.getPermalink(), category0.getPermalink() ); assertEquals( user, category0.getCreateUser() ); // OK; category has createUser. assertEquals( 1, user.getCreatedItems().size() ); // Fails; CreateUser doesn't have Category. assertEquals( category0, user.getCreatedItems().get(0) ); }}@Entity@Table(name="Users")public class Userextends dk.asklandd.moxo.entities.Entity{ @Id @Column(name = "UserID") @SequenceGenerator(name = "USER_ID_SEQ", sequenceName = "USER_ID_SEQUENCE", initialValue = 1, allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_ID_SEQ") private int id = 0; @OneToMany(mappedBy="createUser", // "mappedBy" indicates parent is owning this many-to-one relationship mapping, EJB3iA p. 244+246+278. cascade={CascadeType.ALL}, fetch=FetchType.EAGER ) @OrderBy("createDate DESC") // Pro JPA2 p. 128. private List<Item> createdItems = new ArrayList<Item>(); ... public List<Item> getCreatedItems () { return Collections.unmodifiableList( createdItems ); }}@Entity@Table(name="Items")@Inheritance(strategy=InheritanceType.JOINED) // EJB3iA, p. 287, 285.@DiscriminatorColumn(name="ItemType_DISCR", discriminatorType=DiscriminatorType.STRING)public abstract class Itemextends dk.asklandd.moxo.entities.Entityimplements Comparable<Item>, Serializable{ @Id @Column(name = "ItemID") @SequenceGenerator(name = "ITEM_ID_SEQ", sequenceName = "ITEM_ID_SEQUENCE", initialValue = 1, allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ITEM_ID_SEQ") private int id; @ManyToOne(cascade={CascadeType.ALL}, fetch=FetchType.EAGER) // EJBiA p. 244. @JoinColumn(name="CreateUserID_FK", referencedColumnName="UserID", updatable=true) // EJB3iA p. 278b. private User createUser; // See User.createdItems. ...}@Statelesspublic class UserEAOBeanimplements UserEAO{ @PersistenceContext(unitName = "MoxoPersistenceUnit") protected EntityManager em; ... @Override public User create ( User user ) { em.persist( user ); return user; } ... @Override public User findById ( int userId ) throws EntityNotFoundException { try { User user = em.find( User.class, userId ); if ( user == null ) { throw new EntityNotFoundException(userId); } return user; } catch ( javax.persistence.NoResultException ex ) { throw new EntityNotFoundException( userId, ex ); } }}@Statelesspublic class CategoryEAOBeanimplements CategoryEAO{ ... @Override public Category create ( Category category ) { if ( category == null ) { throw new IllegalArgumentException("null category"); } ... // Relationship persistence, EJBiA p. 314, 316. User managedCreateUser = em.find(User.class, category.getCreateUser().getId()); category.setCreateUser( managedCreateUser ); em.merge( managedCreateUser ); em.persist( category ); return category; } ...}CREATE TABLE Users ( `UserID` INT DEFAULT NULL AUTO_INCREMENT, `Login` varchar(255) NOT NULL, `Password` TINYTEXT NOT NULL, `AccessLevel` TINYINT NOT NULL, `EMail` TINYTEXT NULL, `Homepage` TINYTEXT NULL, `DateOfBirth` DATE NULL, `Male` BOOLEAN NOT NULL, `Country` TINYTEXT NULL, `Location` TINYTEXT NULL, `Organisation` TINYTEXT NULL, `Description` TINYTEXT NULL, `SecurityQuestion` TINYTEXT NOT NULL, `SecurityAnswer` TINYTEXT NOT NULL, `FirstLogon` DATETIME NULL, `LastLogon` DATETIME NULL, `LogonCounts` BIGINT NOT NULL, PRIMARY KEY(`UserID`), UNIQUE KEY `Login` (`Login`)) ENGINE = MyISAM;CREATE TABLE Items ( `ItemID` INT NOT NULL AUTO_INCREMENT, `ItemType_DISCR` TINYTEXT NOT NULL, `ItemType` TINYTEXT NOT NULL, `Name` TINYTEXT NOT NULL, `Description` TINYTEXT, `Permalink` varchar(255) NOT NULL, `CreateUserID_FK` INT NOT NULL, `CreateDate` DATETIME NOT NULL, `ModifyDate` DATETIME, `ParentItemID_FK` INT, `Position` INT NOT NULL, PRIMARY KEY(`ItemID`), UNIQUE KEY `Permalink` (`Permalink`)) ENGINE = MyISAM;CREATE TABLE Categories ( `ItemID_FK` INT NOT NULL, PRIMARY KEY (ItemID_FK)) ENGINE = MyISAM;