child « Transaction « JPA Q&A





1. Retrieving a child object after a commit on an entity object    stackoverflow.com

Lets say I retrieve an entity object that looks like this:

@Entity
public class Mother {
    ...

    @OneToMany(mappedBy = "mother",
        ...

2. Version property of Parent isn't incrementing if I update child    stackoverflow.com

I'm using JPA 2 with Hibernate 3.x. I have two Entity objects Foo and Bar and the relation is like this -

@Entity
public class Foo{
    @Id
   ...

3. JPA: insert into parent and child tables in the same transaction    forums.netbeans.org

Hi, I have a parent table with autogenerated primary key and a many to one table with composite primary key. The partent table entity class has the '@GeneratedValue(strategy = GenerationType.IDENTITY)' The JPA wizard, in addition of creating the entity class for the child table, creates a entity class for the composite primary key of the child class. The entity class of ...

4. Problem excluding child inserts from optimistic locking.    forum.hibernate.org

Hi, I'm having trouble stopping updates to a collection affecting the version of the parent entity, where I would expect @OptimisticLock(excluded = true) to do the trick. I'm using JPA, Hibernate EntityManager 3.4.0.GA. The model features - Unidirectional many-to-one child-parent relationship. - The child class has a reference to its parent. - The parent class does not have a collection of ...

5. Deadlock trying to delete children and parent - JPA2    forum.hibernate.org

I'm getting the following error: 2010-07-14 11:04:45,939 ERROR pool-2-thread-2 ORA-00060: deadlock detected while waiting for resource 2010-07-14 11:04:45,939 WARN pool-2-thread-2 SQL Error: 60, SQLState: 61000 2010-07-14 11:04:45,939 ERROR pool-2-thread-2 ORA-00060: deadlock detected while waiting for resource 2010-07-14 11:04:45,940 ERROR pool-2-thread-2 Could not synchronize database state with session org.hibernate.exception.LockAcquisitionException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:112) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at ...

6. I cant lock a detached object that a child was added !?    forum.hibernate.org

Hi guys it is the third time that i try to be answered about that. I have 3 different and detached objects that comes fron an internet session and add a child for each. like: father.addChild(child) { child.setFather.. father.getChilds.add .. } It generates - One insert and three (in my case), unnecessary updates. insert Child update father update father.. None Father ...

7. Problem with lock() when persisting parent/child    forum.hibernate.org

@Entity(access=AccessType.FIELD) public class User implements Serializable { @Id(generate = GeneratorType.AUTO) private Long id; @ManyToOne(cascade=CascadeType.ALL) //TODO Is this really necessary @NotNull private Collective collective; public Collective getCollective() { return collective; ...

8. Optimistic Locking: Parent/Child, updating a Child collectio    forum.hibernate.org

I know Hibernate's optimistic locking will update the version in the parent when a child is updated. But, I have an issue where a collection in a child is being updated (I see the sql), but I don't see the version field being updated in the parent. Should I expect this as default behavior or am I missing an annotation setting ...

9. Trouble inserting two child records in on transaction.    forum.hibernate.org

I'm testing parent - child relationships, and trying to insert two new child rows in the same transaction. Hibernate raises the following exception message. " a different object with the same identifier value was already associated with the session: [pctest.Child#0]" . Inserting a single child record works fine. I've modeled my test using the simple Parent/Child from the documentation example: ...





10. Hibernate very slow when committing children records    forum.hibernate.org

I am using Hibernate 3.0. I have a one-to-many relationship, let's called it Parent and Child. The problem that I'm having is that commits are horribly slow ( >2 minutes, which is timing out the database connection ). I did some debugging to try to figure out why they are so slow, and here is what I found: * When a ...

11. Optimistic Lock: version Parent when Child is updated    forum.hibernate.org

Hi, currently in Hibernate with a typical (bidirectional & mapped) Parent-Child relationship, the parent gets versioned when a child is added or removed from it. I would like to know if it is possible to version the parent when a child is updated without artificially updating a dummy property of the parent. I'd like to do that to preserve an objects' ...

12. HELP! problem in parent/child saving upon commit    forum.hibernate.org

Author Message paulfromthefuture Post subject: HELP! problem in parent/child saving upon commit Posted: Tue May 19, 2009 11:56 pm Newbie Joined: Tue May 19, 2009 11:38 pm Posts: 1 mapping: Code: ...

13. Children needlessly updated with optimistic locking    forum.hibernate.org

Sorry if this has been asked, but it is terribly hard to search for. We are facing a problem with optimistic locking (optimistic-lock="version") and object graphs. We have written tests to prove that if some field or fields in the parent are modified and saveOrUpdate() is called, then the children are ALL updated, even though they haven't been modified. The VERSION ...