I have a Hibernate SELECT query that keeps throwing a unique constraint violation - which seems odd given that I thought a constraint violation could only occur with an insert?
Probably significant - the unique constraint violation only occurs if I do it right after I do a save on the same DAO.
This is where a do a save for a DAO object:
this.llcPcdSchedDAO.create(newLlcPcdSched);
Which calls this in the BaseDAO object:
public <R> R create(R entity ){
entityManager.persist( entity );
return entity;
}
And this is my SELECT query and its code within the same DAO object - which then throws a unique constraint violation. As I said the constraint violation only occurs when I do the create first.
Query q = entityManager.createQuery("SELECT pcdSchedData FROM LlcPcdSchedData pcdSchedData WHERE pcdSchedData.profileVersion.profileVersionId = :selectId");
q.setParameter("selectId", profileVersionId);
try {
List<LlcPcdSchedData> results = (List<LlcPcdSchedData>)(q.getResultList());
LOG.debug("findByProfileVersionId(Long profileVersionId) successful, result size: " + results.size());
return results;
} catch (Exception e) {
LOG.error("findByProfileVersionId(Long profileVersionId) failed", e);
throw new MnsException(e);
}
Thanks so much.