-
1. Re: how to dis-manage entities?
gsegura Dec 13, 2007 7:06 PM (in response to gsegura)perhaps the topic name was not the best, but I think its a fair question.
So far, only strategy to avoid the entity which holds the collection to get updated is to resort to deal with id alone, a not very object-oriented way to go, so instead of retrieving the ticket.course object fetch just the id:Integer idCourse = (Integer)entityManager .createQuery("select t.course.id from Ticket t where t.code=#{register.code}") .getSingleResult();
But I don't know if dealing with IDs is the proper way to go with respect to ORM techniques.
At the same time this makes think of another issue: the implementation of master-detail editions, which at first, for the neophyte like me, feels natural to handle using nested conversations and sharing full objects but the preferred way to go is using entityhome and its passing-just-the-id technique, again a not very OO-ish way IMHO. -
2. Re: how to dis-manage entities?
gsegura Dec 18, 2007 3:31 AM (in response to gsegura)Probably I'm missing some fundamental knowledge about this issue, I do not think this scenario is that uncommon:
how to retrieve an entity by query (or otherwise) in 'read-only mode' that is, avoid updating it at flush time?
Given that it is been managed by EntityManager, it will be implicitly updated (that is, even without calling EntityManager.merge explicitly), right?
Or could be that, in general, I am using the wrong approach/asking the wrong question? -
3. Re: how to dis-manage entities?
pmuir Dec 18, 2007 4:12 PM (in response to gsegura)"gsegura" wrote:
And that is the problem because when more than one user are inserting CourseNotes to the collection, the second one will get an optimisticlockexception at the time he tries to merge his instance of the course
I would just used managed entities at all times.At the same time this makes think of another issue: the implementation of master-detail editions, which at first, for the neophyte like me, feels natural to handle using nested conversations and sharing full objects but the preferred way to go is using entityhome and its passing-just-the-id technique, again a not very OO-ish way IMHO.
I don't really understand this statement. Why can't you use EntityHome and nested conversations? EntityHome uses objects when inside the conversation (you just pass in the id to get started, probably from outside the conversation). Why is EntityHome not very ooish?
JPA doesn't have a concept of read only entities afaik.