-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Optimistic Locking: Parent/Child, updating a Child collectio
PostPosted: Fri Jul 14, 2006 12:22 pm 
Beginner
Beginner

Joined: Sat Mar 13, 2004 4:00 pm
Posts: 32
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 on the child/child collection?

Thanks,

Rich

Here in a nutshell, is some example code:

Parent.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Inheritance(strategy=InheritanceType.JOINED)
public Parent {

@Column(name="ID")
private Long id;

@Version
@Column(name="MODIFIED_DATE")
private Timestamp modifiedDate;
}

Child.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@PrimaryKeyJoinColumn(name="ID")
public Child extends Parent {

@BatchSize(size=100)
@OneToMany(mappedBy="owner", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
private List<ChildAttribute> attributes

}

ChildAttribute.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
public ChildAttribute {

@Column(name="ID")
private Long id;

@ManyToOne
@JoinColumn(name="CHILD_ID")
private Child owner;

@Column(name="AMOUNT")
private double amount;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.