Environment: Mac OS X
JVM: Java 1.8 u 20
Steps to reproduce
Use the following classes:
/**
Account Class
**/
@Entity @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@uuid") @EntityListeners(AbstractEntity.AbstractEntityListener.class) public class Account extends AbstractEntity implements IAbstractEntity<Long> { @Id @Column(name = "account_id") @GeneratedValue(strategy= GenerationType.TABLE) protected Long id; @Override public Long getId() { return id; } @Override public void setId(Long id) { this.id = id; } @OneToMany(cascade={CascadeType.MERGE, CascadeType.PERSIST}, mappedBy="account", fetch = FetchType.LAZY) @JoinColumn(name = "project_id", unique=true, nullable=false, updatable=false) protected List<Project> projects = new ArrayList<>(); public List<Project> getProjects() { return projects; } public void setProjects(List<Project> projects) { this.projects = projects; } } /** * Project Class */ @Entity public class Project extends AbstractEntity implements IAbstractEntity<Long> { @Id @Column(name = "project_id") @GeneratedValue(strategy= GenerationType.TABLE) protected Long id; @Override public Long getId() { return id; } @Override public void setId(Long id) { this.id = id; } @ManyToOne @JoinColumn(name="account_id", nullable=false) public Account account; public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } } /** Workflow **/ Account account = new Account(); entityManager.persist(account); entityManager.flush(); Project project = new Project(); project.setAccount(account); entityManager.persist(project); entityManager.flush(); account = entityManager.find(account); assertNonNull(account.getProjects());
Expected Result,
account.getProjects() is not null and should contain a project
Note: This scenario was working until running the enhancer on compiled jpa entities