I have a some entities inheriting an AbstractEntity like below.
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class AbstractEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private int id;
@Column(insertable = false, updatable = false)
private String dtype;
public String getDtype() {
return dtype;
}
}
Then I persist some entity that extends AbstractEntity.
ConcreteEntity concreteEntity = new ConcreteEntity();
em.persist(concreteEntity);
If then in some other ejb fetch this entity using
someEntity = query.getResultList().get(0);
the instance returned will have dtype == null
until
em.refresh(someEntity);
I guess this is because the entity manager returns a cached instance that doesnt know which dtype was inserted on em.persist().
But my question is how can I have the query return instances where dtype is set?
Im using glassfish 3.1.2.2 (default jpa provider and the included javadb)