I have been working with hibernate / JPA on JBoss for several months and have one question that I cannot find an answer or solution to.
It seems that when creating a new beans object, I cannot fulfill the request before I even call EntityManager.persist (entityBean), otherwise I will get the following error:
TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing
Example:
Job job = new Job();
Collection<Task> tasks = job.getTasks();
ActionPlan actionPlan = (ActionPlan) entityManager.createNamedQuery("ActionPlan.findByCommand").
setParameter("type", RunOperation.Install).getSingleResult();
Task task = Task.getTask(actionPlan);
task.setActionPlan(actionPlan);
tasks.add(task);
task.setJob(job);
, createNamedQuery "" (, ). ActionPlan Job, NamedQuery (findByCommand) Job. , Job, , Job .
persist() .
, , , , .
, , , - , . ?