I have an entity with a byte[] member variable annotated as a @Lob. I perform some calculations and then I do a merge() call. This is done in a stateless bean. For some reason it does not update the entity. No exceptions are thrown either. Help me www dot stackoverflow dot com, you’re my only hope.
Here is basically what I have.
My entity:
@Entity
@Table(name="my_entity")
public class MyEntity implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private long id;
@Lob
@Column(name="data")
private byte[] data;
// Getters and Setters for both variables...
}
Then I have my stateless bean. I will make the skeleton of exactly what I have. I have a timer that is called every minute which acts on the data.
public @Stateless class MyBean implements IMyBeanRemote {
@PersistenceContext
private EntityManager em;
@Resource
javax.ejb.TimerService timerService;
@Timeout
public void doLogic(javax.ejb.Timer time) {
MyEntity e = getMyEntity(1L);
doMoreLogic(e);
}
private MyEntity getMyEntity(long id) {
return em.find(MyEntity.class, id);
}
private void doMoreLogic(MyEntity entity) {
entity.getData()[0] = 123;
em.merge(entity);
}
}
I think this basically mirrors what my code is doing. When I initially create MyEntity and persist() it, that works.
After typing all this, I decided to do a check to see if I modify that data anywhere else. Turns out I did and I was resetting the data as a debugging test. =( All solved!
Lack of sleep caused me to not see previous debugging code resetting the data.